A launcher plugin that evaluates mathematical expressions and copies results to the clipboard.
- Real-time calculation: Type mathematical expressions directly in the launcher
- Default prefix: Uses
=as the default trigger prefix (configurable) - Safe evaluation: Only allows mathematical operations, preventing code injection
- Clipboard integration: Press Enter to copy the result to clipboard
- Multiple operations: Supports +, -, *, /, ^, %, and parentheses
- Qalc engine support: Optionally use
qalc(libqalculate) for unit conversions, hex, currency, and more - Calculation history: Recent results are shown when the trigger is typed with no expression, newest first (in-memory, configurable size)
- Persistent history: Optionally save history to a JSON file so it survives DMS restarts
dms plugins install Calculator- Mod + ,
- Go to Plugins Tab
- Choose Browse
- Enable third party
- install Calculator
cd ~/.config/DankMaterialShell/plugins
git clone https://github.com/rochacbruno/DankCalculator Calculator
- Open DMS Settings (Ctrl+,)
- Navigate to Plugins tab
- Click "Scan for Plugins"
- Enable the "Calculator" plugin with the toggle switch
- Open the launcher (Ctrl+Space)
- Type the
=prefix followed by a mathematical expression:= 3 + 3 - The result (
6) appears as a launcher item - Press Enter to copy the result to clipboard
You can configure a different trigger prefix or disable it entirely in the settings:
- Open Settings → Plugins → Calculator
- Change the trigger to a custom value (e.g.,
calc,c,math) - Or check "No trigger (always active)" to remove the prefix requirement
- In the launcher, type your configured trigger:
calc 3 + 3or just3 + 3(if no trigger) - Press Enter to copy the result
The plugin supports an alternative calculation engine powered by qalc (libqalculate), which adds unit conversions, hex/binary conversions, currency conversion, and many more features.
To enable it:
- Install
qalcon your system (e.g.,sudo dnf install qalculateorsudo apt install qalc) - Open Settings → Plugins → Calculator
- Change Calculation Engine from "Default (JavaScript)" to "Qalc (libqalculate)"
Qalc examples:
| Expression | Result |
|---|---|
= 12cm to inches |
4.724409449 in |
= 255 to hex |
0xFF |
= 100 USD to EUR |
(current exchange rate) |
= 15% of 200 |
30 |
= sqrt(144) |
12 |
= pi * 3^2 |
28.274333882... |
= 5 gallons to liters |
18.92705892 L |
After calculating expressions, you can recall recent results:
- Open the launcher and type just the trigger (e.g.,
=) - Your recent calculations appear as a list, newest first
- Select any history item to copy its result to clipboard
History is stored in-memory by default and clears when DMS restarts. The number of entries kept is configurable via the History Size setting (default: 10).
To keep history across DMS restarts:
- Open Settings -> Plugins -> Calculator
- Enable Persist History
- Optionally set a custom History File Path (defaults to
<plugins>/calculator_history.json)
When enabled, history is saved to a JSON file every time a result is copied, and loaded back on startup.
binds {
Mod+Shift+C hotkey-overlay-title="Calculator" {
spawn "dms" "ipc" "call" "spotlight" "openQuery" "=";
}
}- Addition:
= 3 + 3→6 - Subtraction:
= 10 - 5→5 - Multiplication:
= 4 * 7→28 - Division:
= 20 / 4→5 - Exponentiation:
= 2 ^ 8→256 - Modulo:
= 17 % 5→2 - Parentheses:
= (5 + 3) * 2→16 - Decimals:
= 3.14 * 2→6.28 - Complex:
= (10 + 5) * 2 - 3 / 3→29
Supports everything the default engine does, plus:
- Unit conversions:
= 12cm to inches,= 5 gallons to liters - Hex/Binary:
= 255 to hex,= 0xFF to decimal - Percentages:
= 15% of 200 - Currency:
= 100 USD to EUR - Functions:
= sqrt(144),= sin(45 deg),= log(1000) - Constants:
= pi * r^2,= c / 2(speed of light)
See the qalc manual for a full list of supported features.
| Expression | Result |
|---|---|
= 3 + 3 |
6 |
= 100 / 4 |
25 |
= 2 ^ 10 |
1024 |
= (5 + 3) * 2 |
16 |
= 3.14159 * 2 |
6.28318 |
= 16 ^ 0.5 |
4 (square root) |
The default JavaScript engine uses safe expression evaluation:
- Only allows numbers, operators (+, -, *, /, ^, %), parentheses, and dots
- Rejects any expressions with letters or special characters (except operators)
- Prevents code injection by validating input before evaluation
The qalc engine delegates evaluation to the qalc binary, which runs as a sandboxed child process.
plugin.json- Plugin manifestCalculatorLauncher.qml- Main launcher componentCalculatorSettings.qml- Settings UIcalculator.js- Safe expression evaluation logic (default engine)QalcService.qml- Qalc process manager singleton (qalc engine)qmldir- QML module directoryREADME.md- This file
Settings are stored in ~/.config/DankMaterialShell/plugin_settings.json under the calculator plugin key:
{
"pluginSettings": {
"calculator": {
"trigger": "=",
"noTrigger": false,
"calcEngine": "default",
"keepLastResults": "10",
"persistHistoryOnFile": false,
"historyFilePath": ""
}
}
}Set "calcEngine" to "qalc" to use the qalc engine, or "default" for the built-in JavaScript engine.
Calculator items don't appear:
- Make sure the plugin is enabled in Settings → Plugins
- Check that you're typing a valid mathematical expression
- Try disabling "No trigger" and setting a specific trigger
Result shows wrong value:
- JavaScript has floating-point precision limitations
- Very large or very small numbers may use scientific notation
- Try switching to the qalc engine for better precision
Qalc engine shows "Calculating..." but no result:
- Make sure
qalcis installed and available in your PATH - Test by running
qalc -t "2+2"in a terminal
Copy to clipboard doesn't work:
- Make sure your system clipboard is accessible
- Check console for error messages
Bruno Cesar Rocha
Same as DankMaterialShell
