Skip to content
Advertisement

How to toggle Autokey phrases?

I want to remap wasd to arrow keys, but then be able to use a hotkey to toggle these (four) phrases so I can go back to wasd behaviour easily. Just putting a window filter on the phrase will not be sufficient. The only ways I can see to do this is to write bash scripts to directly modify the contents of my phrase files, which is obviously a very dirty solution. I am surprised to find that there doesn’t seem to be an easy way to toggle phrases on and off similar to how you can toggle AutoHotkey scripts on Windows. Is there a more sophisticated way of doing this than to use bash scripts to directly overwrite the contents of the .txt files associated with my phrases?

I am okay with solutions that fix my problems but do not use Autokey too, as long as they work on Ubuntu 20.04

Advertisement

Answer

I managed to write a fix by writing a bash script that checks if autokey is currently open, if so it closes it, else it starts it, then I made a keyboard shortcut to this bash script. Closing autokey disables the phrases. It’s not a clean solution, since this only allows me to toggle all of my Autokey phrases at once, but it works for my current use case. Hopefully this can be useful to someone else as well.

if [[ $(xdotool search autokey) ]]; then
    xdotool search autokey windowkill
else
    autokey
fi
Advertisement