Skip to content

Instantly share code, notes, and snippets.

@alex-pat
Last active January 9, 2020 13:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alex-pat/b8dcd3ac3ee61c07535407b56db07f78 to your computer and use it in GitHub Desktop.
Save alex-pat/b8dcd3ac3ee61c07535407b56db07f78 to your computer and use it in GitHub Desktop.
calcutator prompt for awesome wm
-- 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