Last active
January 9, 2020 13:56
-
-
Save alex-pat/b8dcd3ac3ee61c07535407b56db07f78 to your computer and use it in GitHub Desktop.
calcutator prompt for awesome wm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Insert in your rc.lua to globalkeys (may be after mod+x) defining | |
-- In awesome 4.0 : | |
awful.key({ modkey }, "c", | |
function () | |
awful.prompt.run { | |
prompt = "Calculate: ", | |
textbox = awful.screen.focused().mypromptbox.widget, | |
exe_callback = function (text) | |
awful.spawn.easy_async( | |
"python -c \"from math import * ; print(" .. text .. ")\"", | |
function(stdout, stderr, exitreason, exitcode) | |
naughty.notify({ | |
text = 'Result: ' .. string.sub(stdout, 1, -2), | |
position = "top_left", | |
timeout = 5 | |
}) | |
end) | |
end | |
} | |
end, | |
{description = "inline calculator", group = "awesome"}), | |
-- In awesome 3.5 | |
awful.key({ modkey }, "c", | |
function () | |
awful.prompt.run({ prompt = "Calculate: " }, | |
mypromptbox[mouse.screen].widget, | |
function (text) | |
naughty.notify({ | |
text = 'Result: ' .. awful.util.pread("python -c \"from math import * ; print(" .. text .. ",end='')\""), | |
position = "top_left", | |
timeout = 5 | |
}) | |
end) | |
end), |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment