Alternative to AutoHotKey on Linux?

Sueno1123

New Member
Joined
Feb 19, 2022
Messages
19
Reaction score
5
Credits
166
I use AHK religiously on my Windows 10 system, I've automated nigh near everything, and I have keyboard shortcuts for everything (even including copypasta lol). Is there a tool in linux that would allow me to do the same?
 


JasKinasis

Well-Known Member
Joined
Apr 25, 2017
Messages
1,461
Reaction score
2,077
Credits
10,209
Most Linux desktop environments allow you to customise keybinds for most, if not all operations available to you. As you haven’t given any details about which distro you’re running, or which desktop environment, or window manager you’re using - it’s difficult to give exact instructions.

But in more general terms - go into the settings application for your desktop and somewhere in there will be a section for keyboard shortcuts.

The KDE/plasma desktop settings application probably has the most extensive set of customisable keybind options I’ve ever seen.
All other desktop environments offer differing levels of keyboard customisation.

Most tiling window managers allow you to define keybinds for pretty much anything too. (dwm, i3, awesome, xmonad etc etc)
In tiling WM’s - this is done by manually editing the config files it uses, to modify existing keybinds, or add new ones. Then, depending on the tiling WM, you may have to log out and log back in again to apply any new settings. Or you may just have to tell the WM to source/re-read it’s init files, or to restart itself without having to log out.

In the case of dwm (my preferred wm), you have to add custom keybinds to a C header file (config.h) - this requires you to build and install dwm from source. Which isn’t as bad as it sounds, because the entire WM is only ~2000 lines of code, give or take a few lines and it has very few dependencies. So it literally only takes a couple of seconds to build and reinstall it. Then you have to log out and log back in again to restart the WM.

And whether you use a desktop environment, or a window manager - you need to be careful not to define the same keybind for two different things, because if you do that - your de/wm will typically only perform one of those actions.

Edit: Also many Linux applications allow you to customise keybinds used in them.
The level of support for customisation varies from application to application.
Adding/changing keybinds might be possible in the application via it’s GUI, or settings/preference options, or by editing config files, or possibly by editing source code and building/reinstalling manually.
Again, this varies from application to application.

And again, be careful to ensure that none of your in-application keybinds conflict with any of your desktop/wm level keybinds - because the desktop/wm will consume and act upon those conflicting binds and so typically, conflicting binds will not reach the running application.

And if you still require any supplemental support for custom keys, there is also a list of AHK equivalents for Linux here:

I’ve used xdotool a couple of times in the past, for automating GUI button clicking. But I’ve never used it, or any other external applications for setting keybinds.

In dwm, I usually write scripts to automate tasks and then bind a new key to run the script.

In the past, I’ve written a few scripts that use xdotool to manipulate the mouse, to perform repetitive point and click GUI operations. But I haven’t used xdotool for a long time. I try to keep my scripts purely terminal based nowadays.
 
Last edited:
$100 Digital Ocean Credit
Get a free VM to test out Linux!

Members online


Top