Sample Header Ad - 728x90

How to remove need for hacks to run scrot with a keyboard shortcut?

3 votes
1 answer
441 views
I'd like to take screenshots with a keyboard shortcut using scrot --select. I tried adding the following to my rc.lua to use the PrintScr key for this purpose: awful.key({}, "Print", function () awful.spawn("scrot --select") end, {description = "take screenshot of selection", group = "client"}), Unfortunately this results in the following error message in the xsession systemd journal: > giblib error: couldn't grab keyboard:Resource temporarily unavailable It seems scrot needs to grab the keyboard while I'm still holding down the Fn+PrintScr combination. One way to work around this complicates the function a fair bit: awful.spawn.with_shell("sleep 0.5 && scrot --select") The .with_shell and sleep bits are a hack to give me time to release the keys before scrot runs. Which of course means that if I hold down the keys for too long the command still fails with the same error as above. A more elegant workaround does not work reliably. I installed xdotool, set xdotool key XF86Ungrab && scrot --select as the screenshot command, and added grab:break_actions to services.xserver.xkbOptions, but I still get the same error as above *most of the time.* Pressing Fn+PrintScr repeatedly will eventually work, for no discernible reason.
Asked by l0b0 (53368 rep)
Aug 29, 2019, 08:16 AM
Last activity: Aug 29, 2019, 08:27 AM