Creating scripts with AutoKey. Linux and deadly sins part six

Screenshot of AutoKey

If something is making this clear article series is that to do as little as possible with the computer we will have to work a little more beforehand. Using scripts with AutoKey can save us a lot of time and effort, but first you have to create them.

We saw in the previous article that AutoKey is a program that allows you to configure keyboard shortcuts and small scripts in Python. Available in two versions: AutoKey-GTK for GNOME, XFECE Mate, Cinnamon and Budgie desktops and AutoKey-QT for KDE and LXQt desktops

Installing AutoKey

Except for commenting that it is in the repositories, I had not stopped at how to install AotoKey.

Actually, for each distribution we have two installation options. pip, the package manager associated with the Python programming language, and the package manager for each installation.

direct installation

The commands for the different distributions are as follows:

On Debian, Ubuntu and derivatives

sudo apt install autokey-gtk

On Debian derivatives with KDE or LXQt desktop

sudo apt install autokey-qt

in fedora

sudo dnf install autokey-gtk

On ArchLinux

yay -Syy autokey-gtk

Installation by pip

Pip is a package manager without a graphical interface in the style of apt or aptitude but focused on Python. Its utility is to install libraries that are not part of the original installation. Its use was later expanded to include applications.

The advantage of using pip to install AutoKey is that we will have a more updated version than the one in the repositories, although possibly not with the same degree of compatibility.

Let's start by installing (if we haven't already) the pip package manager in our distribution

On Debian, Ubuntu and derivatives

sudo apt install python3-pip

in fedora

sudo dnf install python3-pip

in openSUSE

sudo zypper install python3-pip

On ArchLinux

sudo pacman -S python3-pip

Debemos desinstalar previamente cualquier instalación de AutoKey before installing it using this method.

To install or uninstall we use one of these two commands:

pip install autokey to install

o

pip uninstall autokey to uninstall.

Scripting with AutoKey

AutoKey scripts are the program's solution for when users need to perform more advanced operations than simple text expansion. Using a script, we can run applications, open files/folders, and handle window and mouse events, among other things.

I had told you that the QT version of AutoKey that Ubuntu Studio 22.04 brings in the repositories was not fully translated. In fact, the only thing in our language is the word Accept. Well, the same goes for the GTK version of Ubuntu 22.04, so let's stick with the English commands.

The procedure is the next:

  1. Click on NewFilletScript.
  2. We write the name and click on Accept.
  3. Below the first line we write the script.
  4. In Hotkey click on Set.
  5. We opted for a base key between Control, Alt Shift, Super, Hyper y Goal.
  6. We click on press to set to determine the second key.
  7. We press on Accept.
  8. Click on Save to save the script.

For example, with this script we can open Thunderbird
import subprocess
subprocess.Popen(["usr/bin/thunderbird"])

Getting the most out of this program requires some knowledge. Nor necessarily from Python, it is enough that you know how to search in Google. In the search engine put the task you want to perform + python and you will surely find the script you need. You will only have to copy it, choose the combination of keys that you like the most and that's it.

There are two options in the script configuration window that I didn't mention previously.

  1. Always prompt before executing this script: It asks us for confirmation before executing it.
  2. Show in notification icon menu: Shows a notification of the execution in the toolbar.

The function WindowsFilter it works exactly the same way as for the phrases we saw in the previous article. It is used to select in which application the script is going to be executed.

If you are a user of the traditional version of Ubuntu, there is a problem that you must take into account. Even if you close AutoKey, the program continues to run in the background, but you will not see any indication in the toolbar. You will need to kill the process from the Monitor app.


Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: AB Internet Networks 2008 SL
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.