
KRunner
Way back in July, I was configuring KRunner to do simple text replacements. Basically, I had utilities on macOS that when I typed, for example, xdate it would get replaced with the current date. I used those a lot, but the equivalent utility available for Linux systems was espanso which had a serious deal-killing bug that has been talked about now for over two years but with no viable solution. Instead, I was trying to configure KRunner to do basically the same thing.
I got it working well enough, except that I had to manually enter commands to re-start it after every reboot. I closed with “I will document what works once I have refined and tested it some more.” Well, I’ve finally ironed out the kinks.
ydotool
The key to allowing KRunner to make keyboard substitutions was the ydotool utility. It has to start at runtime, and must be running as root. You can put a line in the root user’s crontab to make it happen. Type the command sudo crontab -u root -e, authenticate, then add this line:
@reboot sleep 30 ; /usr/bin/ydotoold -p /home/twoprops/.ydotool.socket --socket-own=1000:1000
The @reboot specifies that the tool is to be run at every boot. I sleep awhile to make sure that the user environment is fully initialized. It then launches the ydotool daemon with a socket defined in my home directory (/home/twoprops) and with my ID, 1000 in this case, as owner and group (type id on you command line to get your user ID).
diacriticals
Even though KDE, my desktop environment, has a really cool way to enter special characters, for a fast typist like me it can really slow down typing of common words. I created some KRunner shortcuts to manage some of the words I type commonly that are a pain because of diacriticals. Here’s an example for typing ‘ōhi’a:
#!/bin/bash
# Type `ōhi`a with proper diacriticals
export YDOTOOL_SOCKET="/home/twoprops/.ydotool.socket"
ydotool type '`'
ydotool key 100:1 100:0 12:1 12:0 24:1 24:0 # ō
ydotool type 'hi`a '
Note that YDOTOOL_SOCKET must match the path you used in the crontab entry.
—2p