Integrating AutoKey, BASH, and Python, including passing arguments to subroutines


is very useful for automating a host of mundane tasks.

Here is a list of the sorts of tasks for which I use it:

• Sending username and password to web and application challenges

• Making repetitive entries in event logs and websites

• Triggering an action for and responding to the prompts of a host of         applications before shutting down and after a system reboot

• Switching among and triggering subsets of KDE activities

• Entering repetitive remarks and commands while coding

All of these tasks are of the boringly iterative kind, but have slight differences depending on the circumstances. These little differences can be resolved by constructing input parameters and decision keys, then passing these to a common engine.

The input arguments (e.g., username/password, item name/category, application name/response parameters, etc.) are unique to a particular circumstance, but the algorithm for processing the arguments is essentially the same for each type of interaction, varying with only small differences depending on the input. For example:

Username/password challenge pseudocode:
Input username;<tab>;input password;<tab>;<enter>

OOM item/category pseudocode:
Input item;<tab>x6;<category_character>xn;<enter>

Application response pseudocode:
Bring up the application window;enter response parameters;<enter>

The niceties of the pseudocode are considerably more complex, but doable with the appropriate tools. In particular, AutoKey is very sensitive to timing, so we need a generous supply of time.sleep(0.5) statements. Accomplishing the same task in a Python module or BASH script seems to obviate that sensitivity.

The more useful tools I have found include:

Python, in general:
• Learn the differences between Py2.7 and Py3.x

• PyCharm:

if:...elif: case decision struct

• A host of windowing and process modules

- Wnck
- subprocess

autokey-qt (Py3 fork of AutoKey) API, in particular:

• Window tools
wmctrl -a {window title}

We have been able to create functions with these such as:

• Implementing a number of xdotool functions:

xdo_find    A function to find the ID of the window whose title contains a string
xdo_get     A function to set the focus to a specified window
xdo_key     A function to send keystrokes to a specified window
xdo_write   A function to type a string

• Implementing a number of Wnck functions:

check_win   A function to determine if a window exists
min_windows A function to minimize all windows

We shrink the input and case parameters to a string in an AutoKey script that then calls another AutoKey script to implement the various BASH and Python routines.

The canonical structure is this:

arg1 = “xxxxx”
arg2 = "xx xxx xx"
argn = “zzzzz”
arg_string = arg1 + "," + arg2 + "," + ..., + "," + argn
clipboard.fill_clipboard (arg_string)


arg_string = clipboard.get_clipboard() # This is a string
args_list = arg_string.split(',') # This is now a sequence
arg0 = args_list[0]| # So you can pick and choose from the sequence
arg1 =args_list[1]
... # et cetera...
argn =args_list[n]
# Now go *do* something with the arguments

We then use these to add some fun to the boring parts of our life by making them at least a little bit magical:

• When ready to reboot or shut down I issue one single key sequence (;gcaca). It triggers an array of AutoKey, BASH, and Python code that then gracefully closes all windows and applications, responding to challenges about whether to save, etc., and either shutting down or rebooting the machine.

• When ready to restart I issue one single key sequence (;gcasa). It triggers an array of AutoKey, BASH, and Python code that starts up the network, logs in to various SSH sites, triggers maintenance actions on the remote hosts, starts all Linux activities and their respective applications, responds to password challenges, and does all that while I go start the coffee and wash whatever dishes were left in the sink.

• When done (it takes about five minutes on a very fast machine) I issue one final key sequence (;gcafa). It triggers an array of AutoKey, BASH, and Python code that answers system, application, and internet host challenges and brings up the first task window of the day, my work log page.

Here is an explicit example for use with OOM:


More to follow, In Due Course.

Make Linux KDE Plasma Activities Work for You



KDE Plasma “Activities” are a great idea. The idea is that you can collect a number of applications and files in a group, present them together, and not be distracted by a host of other objects irrelevant to that Activity.

They are a superset of “Desktops”,in that they can contain a number of Desktop configurations.

We define a number of different activities with a nickname and keyboard shortcut, create the activities, and populate each Activity with a shell script stack and control the individual application instances with the KDE Window Rules system settings.

Creating Activities

We defined the following activities:





Computer Administration






Software Development





















News and Weather












Activities Manager

We create the activities using the KDE Activities Manager. We access it by right-clicking the desktop and choosing the Activities entry. You can also add the Activities Manager to the task bar.

Scroll to the bottom of the Activities Manager and click on + Create Activity… It brings up this screen (Plasma 5):

  • Assign an icon

  • Do not assign a shortcut in this dialog. These do not work.2

Keyboard shortcuts

Creating keyboard shortcuts is a matter of first creating the Activity then using the Desktop Bus (dbus) to find its 32-character hexadecimal Globally Unique Identifier (GUID), then assign a keyboard shortcut to the GUID.

Finding the GUID

This link was very helpful:

Current Activity GUID

This command lists out the GUIDs for the current Activity:

org.kde.ActivityManager /ActivityManager/Activities CurrentActivity

All activities GUIDs

This command lists out the GUID for all activities:

org.kde.ActivityManager /ActivityManager/Activities ListActivities

The list is ordered by the activities in the Activity manager at the time the command was invoked, so use the Activity Manager to step through each Activity and get its GUID with the previous command..

You then have a nice table when you’re done:

Assigning keyboard shortcut

Now you have everything you need to create a keyboard shortcut for an Activity.

1. Go to

System Settings → Shortcuts → Custom Shortcuts

2. Click on

Edit → New → Global Shortcut → D-Bus Command.

3. Enter a name for the shortcut.

In the Trigger tab, click on the button that says None and press the shortcut you want to use

(e.g. Ctrl+Alt+w).

4. In the Action tab enter the other fields:

Remote application: org.kde.ActivityManager

Remote object: /ActivityManager/Activities

Function: SetCurrentActivity

Arguments: The GUID from the first step, e.g.:


5. Click on Apply

Assigning Applications

Application types

It turns out that there are (at least) four types of applications for each Activity.

  • Activity-specific applications are those that are used in only in a particular Activity. There are a host of these.

  • Multiple-Activity applications are those that are used in more than one but not all activities and need to show different content depending on the Activity.

These include:

Evolution Different views (Inbox, Calendar, Tasks) to be loaded for each Activity

LibreOffice Calc Different spreadsheets for each Activity

  • Common applications are those that are used in all activities but need to show different content depending on the Activity.

These include:

  • Chromium Different url_[Activity].txt to be loaded for each Activity

  • Geany Different Project to be loaded for each Activity

  • Konqueror Different Profile to be shown for each Activity

  • Core applications are applications that must appear in all activities with the same content when switching between activities.

These include:


We then configure each Activity for the four types of applications. This is done with a series of scripts:

The scripts are discussed in more detail here.

The core applications are defined by the KDE Autostart that starts them when the system boots up and then the Window Rules (below) assign them to be Forced to All Activities. So we do not need any script to start these.

This successfully results in having each Activity populated with the desired Activity-specific, multi-Activity, common, and core applications and use cases.

Window Rules

We still have a problem after all that work of having application profiles appear in the wrong Activity.

The solution lies in fully understanding KDE Plasma 5 Window Rules. You can use these rules with sufficient granularity to ensure that your particular application’s use case appears where you want it to appear and nowhere else.

Accessing Window Rules

You can either right-click on a window title bar and choose

More actions → Special application settings

or use the Kicker:

System Settings → Workspace → Window Management → Window Rules

You can define a different rule for a host of different windows here.

Each rule has a host of settings and tabs, but it turns out that only a few matter in this regard.

Window matching tab

The first is the Window Matching Tab:

The Windows Matching screen has three key fields: Description, Window class, and Window title:

The first step is to assign a unique identifier in the Description field, or else you’ll drive yourself nuts with zillions of “Application settings for [application]”, which is to what it defaults.

The next step is to fill in the Window class field. If you come in from the title bar it is already filled out for you (recommended) otherwise you will have to find the right identifier.

Finally you need to decide how to modify the Window title field:

    • Core and Activity-specific applications require no further specification here since they have been fully defined for a Force assignment.

    • Common and Multi-Activity applications must use Window title: Substring Match to define a piece of the Window title that uniquely identifies the particular instance of an application that you wish to assign to a particular Activity.

Size and Position tab

The Size and Position tab has one key field: Activity.

It is modified as follows:

    • Core applications are set to Force: All Activities

    • Common, Multi-Activity, and Activity-specific applications whose Window title has been defined as above then use: Force:[Activity]


Activities are a powerfully useful concept for making work flow more efficient and saving time.

But there is sparse documentation on how to.

We have successfully run this gamut. We hope that this presentation will make life easier for others, and perhaps help the developers in automating this process further.

Like anything else:

“Easy when you know how.”

1C. Andrews Lavarre
Privus Technologies, LLC
EIN: 46-5240799
RI Entity ID: 875119
P.O. Box 606
Newport, RI 02840-0006
(401) 339-7189



Connecting a Bluetooth printer to Linux Mint

The following is how to connect a Bluetooth printer. The key is using a Manual URI with the MAC address without semicolons as the hostname.

Easy when you know how.

This give a good summary of the bluez-tools:

root@Spectre ~ # rfkill list
lists the various adapters, including hci0

root@Spectre ~ # hcitool scan
lists the various devices available, including H470. Note its MAC address:
The AppSocket protocol (sometimes also called the JetDirect protocol, owing to its origins with the HP JetDirect network interfaces) is the simplest, fastest, and generally the most reliable network protocol used for printers. AppSocket printing normally happens over port 9100 and uses the socket URI scheme:

This was the solution:

Kicker → Printers → Add Printer → Select a Printer to Add → Manual URI → Connection →

There are O-rings and then there are Oh!-rings…


The faucets are apparently Italian. Very intricate O-ring valve assembly. The brand appears to be something like Elli Roma.

There is a main shaft with three holes: hot cold, and spout.

The water is mixed and flows to the spout hole and from there into a channel around the shaft at the height of the spout inlet. There is a corrugated O-ring above and below the channel to prevent leakage.

Today it started leaking.

We could not find an exact replacement.

So we took two regular O-rings:

• 30 mm i.d., 3 mm thickness
• 30 mm i.d., 2.5 mm thickness

and put them in the channel for one of the corrugated O-rings and repeated for the other.

It works!


Transition Evolution to a new installation

We recently converted the operating system from openSUSE Leap 42.2 to Linux Mint (8) KDE. Doing so required transfering our Evolution data to the new OS.

We keep the Evolution data on a separate partition (/data/comms/internet/evolution) so that it doesn’t get corrupted by a system change. We then link the appropriate elements of that data to the default locations under /home/user/.

The best method is to use File→Backup/Restore. This writes the data (messages, contacts, etc.—but not the configuration files) to a tar.gz file. It You can restore from that file and then copy (write-into) any other message files you may have that were not in the backup tree.

However, restore will restore to /home/user/, not /data/comms/internet/. So we use an external program (LuckyBackup) to backup
to an external medium. Restoration is simply a matter of reconstructing the links from


There are two links that must be constructed when restoring:
man ln:
ln [OPTION]... TARGET... DIRECTORY (3rd form)
In the 3rd and 4th forms, create links to each TARGET in DIRECTORY.

The configuration files:
 ln -s /data/comms/internet/evolution/ /home/user/.config/

This links the configuration files. .config does not contain the message tree, so ignores them:
The message tree:
   ln -s /data/comms/internet/evolution /home/user/.local/share/

This links the message tree to its proper home in

Ensure that you give the LuckyBackup enough time when backing up separately:
It builds the tree quickly but takes time to transfer the messages. You end up with an empty tree if you don’t give it enough time.

==== Background ====


Evolution format changed from 2.32 to 3.x. In both cases, the data was stored in ~/.local/share/evolution/mail/local/ according to XDG Base Directory Specification ( Inside that data directory, the format and the tree structure changed.

The 3.x format

In Evolution 3.x, the emails were stored in Maildir instead of Mbox format.

In Maildir format, a mail folder is composed of one directory (often called Maildir in Linux) containing 3 subdirectories called cur, new, and tmp. The subdirectory cur contains one file for each email of the folder, i.e., one file per email instead of one file containing all emails as in Mbox format.

File structure

This is the top level file structure of



This is the structure of the mail folder

The folders folder contains an xml file for each folder

The .local folder contains a directory tree mirroring the files in folders:

Each topic branch has three sub-branches (cur, new, tmp). cur contains the actual messages:

The program seems to be self-healing: when you leave the directory it reconstructs the index and any missing message
headers have been removed.

Chromium video playback [Solved]

We were unable to view video in Chromium
Version 54.0.2840.100 (64-bit)
Linux openSUSE 42.1.

The solution is here:
in Chromium.

Override software rendering list Mac, Windows, Linux, Chrome OS,
 AndroidOverrides the built-in software rendering list and
 enables GPU-acceleration on unsupported system configurations.

Restart Chromium.

Problem solved.

But then we could not open some websites:

We had downgraded Chromium to v54.0 from v56.0 to allow chromium-ffmpegsumo so that we could play videos. But that broke SSL certificates derived from Symantec:!topic/chrome/YLX1__NgPj0

Most of the reports here are to running an old and out-of-date Chromium v. 53 on Linux distros. Specifically this error will happen when using out of date Chrome/Chromium to go to secure websites who use SSL security certificates issued by Symantec or Symantec associated groups, including GeoTrust, Thawte, and VeriSign.

Craig’s list:
Issuer: GeoTrust SHA256 SSL CA

zypper se -s chromium-ffmpeg
It only returns chromium-ffmpegsumo.

We reupgraded to v.56 and now everything works.

Twilight zone…