In the quest for an analogue on Linux of Autohotkey that exclusively runs on Microsoft Windows, neither autokey nor espanso proved as reliable.
Instead, this little shell script snippy.sh
that depends on
expands (by typing it out via xdotool
) a fuzzily selected string from a popup menu (provided by rofi
).
Each such string, say LGTM
, is stored as the name of a file ~/.snippy/LGTM
inside ~/.snippy
that expands to the content of the file.
For example, if ~/.snippy/LGTM
reads Looks good to me!
, then fuzzily selecting LGTM
writes out Looks good to me!
.
This works quite universally, that is, in every text box, editor, ... because xdotool
simulates key presses.
To call it by a global key binding, a daemon such as xbindkeys (or sxhkd) is needed.
-
Save this script, say to
~/bin/snippy.sh
bymkdir --parents ~/bin && curl -fLo https://raw.githubusercontent.com/Konfekt/snippy.sh/master/snippy.sh ~/bin/snippy.sh
-
mark it executable by
chmod a+x ~/bin/snippy.sh
,
To launch snippy.sh
by a global keyboard shortcut, say by pressing, at the same time, the Microsoft Windows
key and S
:
-
install
xdotool
,rofi
and, say,Xbindkeys
(orSxhkd
), (for example, onopenSUSE
bysudo zypper install xbindkeys
respectivelysudo zypper install xdotool rofi sxhkd
) -
add to
~/.xbindkeysrc
a key binding that launchessnippy.sh
, say"$HOME/bin/snippy.sh" Mod4 + s
-
start
xbindkeys
.
To start xbindkeys
automatically at login, say on a KDE
desktop environment, put a file xbindkeys.sh
reading
#! /bin/sh
xbindkeys
into ~/.config/autostart-scripts/
.
This script is based on snippy and passmenu; all credit shall be theirs and their licenses apply.