[How To] use Autokey in place of scripting

NOTE: Does not work well on Wayland.

Many of us need to run rather long terminal commands or run simple but frequent terminal commands.
Rather than typing the full thing (which is good for memorization, but not so good for wits and time), you can use Autokey.

If you have ever used Macros, this is similar.

To install it on Zorin OS with GTK:
Download the latest release from here.
Open a terminal in your Downloads directory or change directory to it with cd ~/Downloads
Run (Replace 0.96.0 with the version number you actually download. Alternatively, if these two are the only .deb packages in your Downloads folder, you can simply run sudo dpkg -i *.deb):

sudo dpkg --install autokey-common_0.96.0_all.deb autokey-gtk_0.96.0_all.deb

For those of us using Plasma D.E. on Zorin OS, you can grab the Qt autokey-qt_${VERSION}_all.deb version, instead of the gtk version.
Due to missing dependencies, you now will mot likely need to run

sudo apt --fix-broken install

That should do it. It is now installed.
You can launch from the app menu: Autokey
In the open window, you can set your phrases and assign a hotkey for them. This can be passwords or common commands.

Remember, when setting your hotkey for a Terminal Command, to select Clipboard (Ctrl+Shift+V) from the "paste using" Drop Down Menu.

1 Like

By the way, macOS is a troublesome name because it is easily mistaken for macros.

2 Likes

Me neither, good to know. Although I wonder what's the difference between shell aliases, macros and this? :thinking:

1 Like

The major difference between macros and aliases is that macros can contain argument placeholders.

AutoKey is a desktop automation utility for Linux and X11. It allows the automation of virtually any task by responding to typed abbreviations and hotkeys. It offers a full-featured GUI that makes it highly accessible for novices, as well as a scripting interface offering the full flexibility and power of the Python language.

2 Likes

I'll have to check it out although then, sounds quite powerful specially if you can extend it with your own scripts. Thanks!

1 Like

We all run into things we don't know. It's up to you to decide on your interest in knowing it and taking the time to learn it.

I like that it's written in and utilizes python. That reduces the restrictions of what you can do, it's only a matter of finding out how.

1 Like

I searched up and found a Guide that can help users to learn how to use Autokey the most effectively:
https://www.makeuseof.com/use-autokey-to-automate-repetitive-tasks-on-linux/

I just added these two commands to AutoKey:

I can remember sudo sync just fine. But the clearing of RAM, I never remember it right.
Do not forget to repeat sudo sync after clearing the RAM (Important!)

3 Likes

I've set the Free Memory macro up in Settings > Keyboard Shortcuts.

Scroll all the way to the bottom, click the '+' button, then enter:

gnome-terminal -- /bin/sh -c 'echo Recovering Memory...; echo Wait...; sudo sync; sudo sysctl -w vm.drop_caches=3; sleep 30; sudo sync'

I named it "Recover Memory", and gave it the key combination of Super+M. Then I very carefully painted the edges of the keys I'd set up for macros with blue. I've got Super+M for "Recover Memory", Super+U for "Update All", Super+L for "Flush Logs" and Super+S for "SCRUB Drives" (for the ZFS file system). That way, every time I look at the keyboard, I'm reminded of the macros.

1 Like