BreakingExpress

Improve your productiveness with this Linux automation software

AutoKey is an open supply Linux desktop automation software that, as soon as it is a part of your workflow, you may surprise the way you ever managed with out. It could be a transformative software to enhance your productiveness or just a technique to scale back the bodily stress related to typing.

This article will have a look at the best way to set up and begin utilizing AutoKey, cowl some easy recipes you possibly can instantly use in your workflow, and discover a number of the superior options that AutoKey energy customers could discover engaging.

Install and arrange AutoKey

AutoKey is out there as a software program package deal on many Linux distributions. The challenge’s installation guide comprises instructions for a lot of platforms, together with constructing from supply. This article makes use of Fedora because the working platform.

AutoKey is available in two variants: autokey-gtk, designed for GTK-based environments akin to GNOME, and autokey-qt, which is QT-based.

You can set up both variant from the command line:

sudo dnf set up autokey-gtk

Once it is put in, run it through the use of autokey-gtk (or autokey-qt).

Explore the interface

Before you set AutoKey to run within the background and robotically carry out actions, you’ll first need to configure it. Bring up the configuration person interface (UI):

autokey-gtk -c

AutoKey comes preconfigured with some examples. You could want to depart them when you’re getting acquainted with the UI, however you possibly can delete them if you want.

The left pane comprises a folder-based hierarchy of phrases and scripts. Phrases are textual content that you really want AutoKey to enter in your behalf. Scripts are dynamic, programmatic equivalents that may be written utilizing Python and obtain mainly the identical results of making the keyboard ship keystrokes to an energetic window.

The proper pane is the place the phrases and scripts are constructed and configured.

Once you are blissful together with your configuration, you may most likely need to run AutoKey robotically whenever you log in in order that you do not have to begin it up each time. You can configure this within the Preferences menu (Edit -> Preferences) by deciding on Automatically begin AutoKey at login.

Correct widespread typos with AutoKey

Fixing widespread typos is a simple downside for AutoKey to repair. For instance, I constantly kind “gerp” as an alternative of “grep.” Here’s the best way to configure AutoKey to repair most of these issues for you.

Create a brand new subfolder the place you possibly can group all of your “typo correction” configurations. Select My Phrases within the left pane, then File -> New -> Subfolder. Name the subfolder Typos.

Create a brand new phrase in File -> New -> Phrase, and name it “grep.”

Configure AutoKey to insert the right phrase by highlighting the phrase “grep” then coming into “grep” within the Enter phrase contents part (changing the default “Enter phrase contents” textual content).

Next, arrange how AutoKey triggers this phrase by defining an Abbreviation. Click the Set button subsequent to Abbreviations on the backside of the UI.

In the dialog field that pops up, click on the Add button and add “gerp” as a brand new abbreviation. Leave Remove typed abbreviation checked; that is what instructs AutoKey to switch any typed incidence of the phrase “gerp” with “grep.” Leave Trigger when typed as a part of a phrase unchecked in order that in the event you kind a phrase containing “gerp” (akin to “fingerprint”), it will not try to show that into “fingreprint.” It will work solely when “gerp” is typed as an remoted phrase.

Restrict corrections to particular purposes

You could need a correction to use solely whenever you make the typo in sure purposes (akin to a terminal window). You can configure this by setting a Window Filter. Click the Set button to outline one.

The best technique to set a Window Filter is to let AutoKey detect the window kind for you:

  1. Start a brand new terminal window.
  2. Back in AutoKey, click on the Detect Window Properties button.
  3. Click on the terminal window.

This will auto-populate the Window Filter, probably with a Window class worth of gnome-terminal-server.Gnome-terminal. This is ample, so click on OK.

Save and check

Once you are happy together with your new configuration, make sure that to reserve it. Click File and select Save to make the change energetic.

Now for the grand check! In your terminal window, kind “gerp” adopted by an area, and it ought to robotically right to “grep.” To validate the Window Filter is working, strive typing the phrase “gerp” in a browser URL bar or another utility. It mustn’t change.

You could also be considering that this downside may have been solved simply as simply with a shell alias, and I would completely agree! Unlike aliases, that are command-line oriented, AutoKey can right errors no matter what utility you are utilizing.

For instance, one other widespread typo I make is “openshfit” as an alternative of “openshift,” which I kind into browsers, built-in improvement environments, and terminals. Aliases cannot fairly assist with this downside, whereas AutoKey can right it in any event.

Type continuously used phrases with AutoKey

There are quite a few different methods you possibly can invoke AutoKey’s phrases that will help you. For instance, as a website reliability engineer (SRE) engaged on OpenShift, I continuously kind Kubernetes namespace names on the command line:

oc get pods -n openshift-managed-upgrade-operator

These namespaces are static, so they’re superb phrases that AutoKey can insert for me when typing ad-hoc instructions.

For this, I created a phrase subfolder named Namespaces and added a phrase entry for every namespace I kind continuously.

Assign hotkeys

Next, and most crucially, I assign the subfolder a hotkey. Whenever I press that hotkey, it opens a menu the place I can choose (both with Arrow key+Enter or utilizing a quantity) the phrase I need to insert. This cuts down on the variety of keystrokes I have to enter these instructions to only a few keystrokes.

AutoKey’s pre-configured examples within the My Phrases folder are configured with a Ctrl+F7 hotkey. If you stored the examples in AutoKey’s default configuration, strive it out. You ought to see a menu of all of the phrases accessible there. Select the merchandise you need with the quantity or arrow keys.

Advanced AutoKeying

AutoKey’s scripting engine permits customers to run Python scripts that may be invoked via the identical abbreviation and hotkey system. These scripts can do issues like switching home windows, sending keystrokes, or performing mouse clicks via supporting API features.

AutoKey customers have embraced this characteristic by publishing customized scripts for others to undertake. For instance, the NumpadIME script transforms a numeric keyboard into an previous cellphone-style textual content entry technique, and Emojis-AutoKey makes it straightforward to insert emojis by changing phrases akin to :smile: into their emoji equal.

Here’s a small script I arrange that enters Tmux’s copy mode to repeat the primary phrase from the previous line into the paste buffer:

from time import sleep

# Send the tmux command prefix (modified from b to s)
keyboard.send_keys("<ctrl>+s")
# Enter copy mode
keyboard.send_key("[")
sleep(zero.01)
# Move cursor up one line
keyboard.send_keys("k")
sleep(zero.01)
# Move cursor to begin of line
keyboard.send_keys("0")
sleep(zero.01)
# Start mark
keyboard.send_keys(" ")
sleep(zero.01)
# Move cursor to finish of phrase
keyboard.send_keys("e")
sleep(zero.01)
# Add to repeat buffer
keyboard.send_keys("<ctrl>+m")

The sleeps are there as a result of often Tmux cannot sustain with how briskly AutoKey sends the keystrokes, and so they have a negligible impact on the general execution time.

Automate with AutoKey

I hope you’ve got loved this tour into keyboard automation with AutoKey and it provides you some brilliant concepts about the way it can enhance your workflow. If you are utilizing AutoKey in a useful or novel means, be sure you share it within the feedback under.

Exit mobile version