Fundamentals 9 min read

Boost Linux Productivity: Install and Master AutoKey for Keyboard Automation

This guide walks you through installing AutoKey on Linux, configuring its UI, creating typo‑fix phrases, setting window filters, assigning hotkeys, and writing Python scripts to automate repetitive typing tasks, helping you streamline your workflow and reduce keystroke effort.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Boost Linux Productivity: Install and Master AutoKey for Keyboard Automation

Installation and Setup

AutoKey is an open‑source Linux desktop automation tool. It provides two variants: autokey-gtk for GTK desktops and autokey-qt for Qt desktops. On Fedora the GTK variant can be installed with: sudo dnf install autokey-gtk After installation start the program with autokey-gtk (or autokey-qt for the Qt version). To have AutoKey start automatically at login enable the option Automatically start AutoKey at login in the Preferences dialog.

Exploring the User Interface

Run autokey-gtk -c to open the configuration window. The left pane shows a hierarchical tree of folders that contain Phrases (static text) and Scripts (Python code). The right pane is used to edit the selected item.

Correcting Common Typos

To replace a frequently mistyped word, create a sub‑folder (e.g., Typos) under My Phrases . Add a new phrase named grep with the content grep. Then create an abbreviation gerp that expands to this phrase. Ensure the options Remove typed abbreviation is checked and Trigger when typed as part of a word is unchecked so the correction only occurs when the typo is typed as a standalone word.

Limiting Corrections to Specific Applications

Use the Window Filter to restrict a phrase or script to particular applications. For a terminal, detect the window class (e.g., gnome-terminal-server.Gnome-terminal) via the Detect Window Properties button and set that value as the filter.

Assigning Hotkeys

A folder can be bound to a hotkey (for example Ctrl+F7). Pressing the hotkey opens a menu listing the phrases in that folder; the desired phrase can be selected with arrow keys + Enter or by typing its number.

Advanced Automation with Python Scripts

AutoKey’s script engine allows Python scripts to send keystrokes, switch windows, or perform mouse clicks. Below is a self‑contained script that enters tmux copy mode, selects the first word of the previous line, and copies it to the clipboard. The sleep calls give tmux time to process each injected keystroke.

from time import sleep
# Send tmux command prefix (Ctrl+s instead of the default Ctrl+b)
keyboard.send_keys("Ctrl+s")
# Enter copy mode
keyboard.send_key("[")
# Move cursor up one line
keyboard.send_keys("k")
sleep(0.01)
# Move to start of line
keyboard.send_keys("0")
sleep(0.01)
# Start selection (set mark)
keyboard.send_keys(" ")
sleep(0.01)
# Move to end of the first word
keyboard.send_keys("e")
sleep(0.01)
# Copy selection to tmux buffer (Ctrl+m)
keyboard.send_keys("Ctrl+m")

Typical workflow: create phrases for frequently used commands (e.g., Kubernetes namespace strings), group them in folders, assign hotkeys, and optionally add Python scripts for more complex actions.

Saving and Testing

After configuring phrases, abbreviations, window filters, and hotkeys, save the configuration via File → Save . Test the setup by typing the defined typo (e.g., gerp) in a terminal; it should expand to grep. The window filter ensures the correction does not fire in unrelated applications such as web browsers.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

PythonAutomationLinuxproductivityKeyboardAutoKey
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.