Compiling Espanso
The one software I actually use on all my machines, be it at work or at home, is the Text Expander Espanso.
A text expander is a program that detects when you type a specific keyword and replaces it with something else. This is useful in many ways:
- Save a lot of typing, expanding common sentences.
- Create system-wide code snippets.
- Execute custom scripts.
- Use emojis everywhere.
Espanso supports Linux, macOS, and Windows. Perfect, since I’m required to use Windows at work.
At home most computers run Ubuntu, which was fine until last weekend, when I upgraded the first one to Ubuntu 22.04, which uses Wayland instead of X11. Espanso’s Wayland support is marked experimental, and I soon realized why.
To make a long story short: The current developer version of Espanso is working all right. The last release version? Not so much. So I needed to do something I haven’t done in quite a while, compile a program myself instead of just using one of the thousand packages a Linux distribution provides.
Fortunately, the process was as easy as ever.
I started by setting up a virtual machine with Vagrant. This step is completely optional, but didn’t want to install a lot of packages on my main computer. The virtual allows my to keep everything under wraps and discard it after I’m done with it.
The Vagrant comfiguration (called Vagrantfile
) is as easy as it comes:
Vagrant.configure("2") do |config|
config.vm.box = "bento/ubuntu-22.04"
end
This will configure a standard Ubuntu 22.04 after running vagant up
.
After booting the virtual machine and sshing into it (vagrant ssh
), I just needed to download and compile Espanso and its build environment. Fortunately its documentation is up to par and I needed just a few minutes to get everything running. The necessary commands were:
sudo apt update
sudo apt install git build-essential libx11-dev libxtst-dev libxkbcommon-dev libdbus-1-dev libwxgtk3.0-gtk3-dev
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
git clone https://github.com/espanso/espanso.git
cd espanso/
. ~/.cargo/env
cargo install rust-script --version "0.7.0"
cargo install --force cargo-make --version 0.37.5
cargo make --env NO_X11=true --profile release -- build-binary
I finished by moving the resulting espanso
executable to /usr/local/bin
and setting its capabilities with sudo setcap "cap_dac_override+p" $(which espanso)
.
Finally, Espanso works at it used to again, and I’m confident that it will do so on Ubuntu 24.04, when I decide to upgrade in the future. Recompiling everything should be no problem then, I will just have to replace 22.04
with 24.04
in the Vagrantfile
to build a new virtual machine and run the script above.