Bug 499955

Summary: Calculator should support unit conversions
Product: [Plasma] krunner Reporter: Grant Gryczan <grantgryczan>
Component: calculatorAssignee: Plasma Bugs List <plasma-bugs-null>
Status: REPORTED ---    
Severity: wishlist CC: alexander.lohnau, aoeui, cwo.kde, ilikefoss, natalie_clarius
Priority: NOR    
Version First Reported In: 6.3.0   
Target Milestone: ---   
Platform: Neon   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: An image showing gibberish calculator output

Description Grant Gryczan 2025-02-13 05:48:54 UTC
SUMMARY
I expected unit conversions to work in the KRunner with the same conventional syntax that works in Windows search, Google Chrome search, ChromeOS search, and (if I recall correctly) Pop!_OS search: "(expresion) to (unit)" or "(expression) into (unit)" should give the output of the specified expression in the specified unit. But I was surprised to find this has not been implemented in KDE search.

Currently, inputting a conversion like "5 in to ft" outputs gibberish like "5 * int(1 B*ft)". (See attached image.)

SOFTWARE/OS VERSIONS
KDE Plasma Version: 6.3.0
KDE Frameworks Version: 6.11.0
Qt Version: 6.8.2

ADDITIONAL INFORMATION
There is a separate unit converter search plugin, but it's far less powerful because:

1. It only supports a specific set of basic units. You can't do anything complex like "5 GiB/min", and this couldn't even theoretically be designed in a way that follows from the unit converter's current design, since it would have to show every combination of units for gibibytes and for seconds. Adding more units to the input would increase the number of outputted unit combinations exponentially, which is impractical for users to scroll through. I'd really like to be able to do more complex conversions like "5 GiB/min to MB/s". Google Chrome's search bar, for example, tells me this equals "89.4784853 MB / s".

2. You can't do math with units, like "6 mph * 7 hr". Currently, the calculator can handle this, but it chooses the output units arbitrarily. For example, "6 mph * 7 hr" outputs "67.592448 km". This is expected! But if I want the output in miles (which would make sense considering I inputted miles per hour), then I would expect to be able to add "to mi" to the end. Currently, "6 mph * 7 hr to mi" outputs the gibberish "67.592448 Mt*B*m^2". I have never even heard of these units. Windows search tells me my input equals "42 miles".

It may be out of scope for this suggestion, but to be honest, I would further suggest getting rid of the default unit converter plugin in favor of unifying the unit conversion functionality into the calculator the way I described above, and the way that every other search bar calculator I've used before works. I think having these two use cases (that heavily overlap each other) unified into one plugin would make the most sense and be the most usable, and I think that if this suggestion is implemented, the unit converter becomes redundant. I've not seen anyone else display a list of possible units as outputs the way KRunner does. I find the unit converter difficult or less convenient to use, compared to simply entering the output unit and seeing the desired result immediately. That way, I don't have to skim through a bunch of results, and be limited to only one basic unit.
Comment 1 Grant Gryczan 2025-02-13 05:50:36 UTC
Created attachment 178246 [details]
An image showing gibberish calculator output
Comment 2 John 2025-02-13 06:19:37 UTC
On Plasma 6.3.0 the same input shows the same result like in the printscreen.
The only way I could get the proper result was by writing this:
"5 inches to feet".
Short names doesn't seem to work, maybe because they are too confusing and conflicting with other things that might be shortened the same.
BTW, Krunner also has another problem:
It doesn't lets you to Right-click -> Copy the selected text as it refuses to show the contextual menu!
Comment 3 Grant Gryczan 2025-02-13 06:21:50 UTC
"5 inches to feet" shows a result from the unit converter, not the calculator. (And I explained why the unit converter is insufficient.)
Comment 4 cwo 2025-02-14 12:07:55 UTC
>The only way I could get the proper result was by writing this:
"5 inches to feet".

"5in to feet" works as well here, as does '5" to feet' and even "5 feet to in". I think "in" may trigger some additional parsing in "5 in to feet", as "in" is also a keyword for e.g. time zone conversions.

(Neither are what the original reporter requested though, they're just the unit converter)

>  It doesn't lets you to Right-click -> Copy the selected text as it refuses to show the contextual menu!

There's a button you can click/tab to and press, and you can also press shift-return. I'm not sure a context menu would make sense as it would just have a single entry in it.