You are not logged in.
I am trying to find an alternative to AutoKey for keyboard macros. I've seen some suggest sxhkd combined with xdotool, which is what I'm trying here.
I want to implement macros whereby when I press alt + j,i,k,l it simulates left,up,down,right arrow keys respectfully.
I have the contents of ~/.config/sxhkd/sxhkdrc as:
alt + j
xdotool key Left
alt + i
xdotool key Up
alt + k
xdotool key Down
alt + l
xdotool key RightI then run sxhkd -c ~/.config/sxhkd/sxhkdrc. No effect.
I know that the sxhkd daemon is running, because when I change the config to be
alt + j
xdotool helppressing alt + j results in the help menu to be outputted to the terminal. It's only when I try doing xdotool key X or xdotool type "XYZ" that it doesn't work.
I also know that xdotool on it's own is not the problem. When I manually run xdotool key Up, it simulates an up arrow key press in whatever window is focused.
I found This github issue thread that says a workaround is to "pass the synthetic event directly to a specific window." and gives the following example:
shift+s
xdotool getwindowfocus type --window %@ SI've updated my sxhkdrc to reflect this:
alt + j
xdotool getwindowfocus key --window %@ Left
alt + i
xdotool getwindowfocus key --window %@ Up
alt + k
xdotool getwindowfocus key --window %@ Down
alt + l
xdotool getwindowfocus key --window %@ Rightbut still no success. And again, manually running xdotool getwindowfocus key --window %@ Up will successfully cause the up arrow key to be simulated in the active window, it's only through the sxhkd that it fails.
One thing that might be worth noticing is that when I try using the macros in a terminal window, the caret blinks, whereas when the macros are turned off doing alt + j has no effect.
I really need to get this working, or find some other alternative software to implement macros. Any help towards either of those would be appreciated.
Last edited by michaelmoreno (2022-02-05 19:52:24)
Offline
sxhkd will likely cause an active grab when the shortcut is fired, try to briefly sleep before hitting the key w/ xdotool (it has a built in sleep feature, but you cal also try /bin/sleep)
Last edited by seth (2022-02-05 21:11:26)
Offline