wolph / alfred-converter

Alfred unit converter is a smart calculator for Alfred with support for unit conversions to make it a bit comparable to the Google Calculator and Wolfram Alpha.
93 stars 15 forks source link

Add variable to enable or disable fractional units #38

Closed penntheone closed 1 year ago

penntheone commented 2 years ago

When converting from metric to imperial, for example, 10 cm to in, I personally only care that 10 cm = 3.93 in. The current configuration is clutchy with fractions, mixed fraction, and a thousandth of an inch, the latter of which is a little infuriating considering that I have to manually move the decimal point of 3937.007874 three digits over to get my actual result. There should be a variable disabling fraction, or at the very least move result 3.93 in at the top.

wolph commented 2 years ago

I agree that this should be configurable, I'm planning to add it.

As for moving the results to the top, Alfred decides on the order and learns from your behaviour. If you select the 3.93 result a few times (i.e. press enter) it will suggest that first the next time.

videopilot commented 2 years ago

Configurable is great. I definitely need both fractions and decimals, but I would love to set the order of results (including whether to show 1 1/8 before 9/8).

But speaking of fractions, going from metric to imperial, I often end up with a denominator of 127, 254, or 508 or something, and none are as useful to me as smaller power-of-two denominator fractions, even if those get rounded.

It would be nice to be able to set a max precision for fractions, and then maybe show rounded fractions with a "~" before them or something.

image image
wolph commented 2 years ago

That would be useful indeed.

As for the order, that's decided by Alfred and learns from your behavior. If you often select a type of result it will put that at the top

wolph commented 1 year ago

The latest release includes an improvement from @aaronkollasch that limits the number of fractional options. It's still far from perfect but it should be a lot better already :)

With regards to the configurable option, this will be the last release that supports older versions of Alfred that don't support the user configurable options. The future versions will include dropdowns such as the one in your screenshot for easier use.

andreatitolo commented 1 year ago

Just following up on this as I had the same issue. I see that inside the workflow folder the constant.py file contains the variable OUTPUT_DECIMALS which is set to 8 by default. For now, I edited this to 2, to return the decimals I want. I wonder if this could be put as a variable using a similar thing as os.environ.get('OUTPUT_DECIMALS') or 8.

I tried this on my own, but I have almost zero python knowledge and even less will to learn now, so I got an error and just gave up 😂

wolph commented 1 year ago

@andreatitolo I've added it as a configurable option now: image

I'm currently working on the feature that @videopilot suggested

wolph commented 1 year ago

We now have an approximate conversion whenever an exact conversion is not available: image

It can be configured through the Fraction display precision and it will show values up to the Maximum fraction deviation percentage

image