How to take screenshot(using selection) in awesome wm via scrot

Tried:

awful.util.spawn("scrot -s")
awful.util.spawn("urxvt -e \"scrot -s\"")
os.execute("scrot -s")

and all possible combinations even with sleep.
Also tried daemonize.
Nothing works =( P.S. All commands are in key bindings, if I replace scrot -s with scrot, all works, except selecting area.

1

2 Answers

Since you have arguments in command line awful.util.spawn_with_shell() should be used. This

awful.util.spawn_with_shell("sleep 0.5 && scrot -s")

works fine for me.

I have been struggling with this too. spawn_with_shell is not the solution that makes it work for me. The screen flickers when I press the according hotkey, so that's configured correctly and when I press Win+r (run) and type path/to/screenshot.sh, that also works. This is the script following the shebang

scrot -s '%Y-%m-%d_$wx$h_scrot.png' -e 'mv $f /home/sam/Pictures/Screenshots'

This are the things I've tried:

screenshot = "/home/sam/run/screenshot.sh"
awful.spawn.with_shell(screenshot)

What does work is executing the bash scripts with the terminal: These are my variable definitions at the top of the page

screenshot = "/home/sam/run/screenshot.sh"
screenshot_cmd = terminal .. " -e " .. screenshot

And then way more down the file, I have these (both working)

awful.key({ modkey , }, "#107", function () awful.spawn.with_shell(screenshot_cmd) end, {description = "take screenshot", group = "launcher"}),
awful.key({ modkey , "Shift" }, "p", function () awful.spawn(screenshot_cmd) end, {description = "take screenshot", group = "launcher"}),

Unfortunately, the latter also opens a terminal window, which is not a desirabe behaviour (But at least, something is working

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like