Dunst: a lightweight notification daemon

With this tool, you can configure an event (low battery, USB device plugged…) to send a notification to your desktop environment. As you may know, I am using Arch Linux with Spectrwm as desktop environment, so I will show you how to configure Dunst to work with it, but it may also work with others.

To go a bit further and to follow up on the articles I just wrote about creating an OpenPGP key and saving it on a Yubikey, I’ll show you how to receive a notification as soon as an interaction is expected: touch the key to validate an action (sign, decrypt or authenticate).

Information and requirements

These elements are to be taken into consideration to follow this article:

Install required utilities

Some explanations about these packages:

yay -S libnotify dunst yubikey-touch-detector

Dunst’s configuration

Enable Dunst at boot

Copy the following snippet into the config file used by the program to start the X Window System server. Here, it is located at ~/.xinitrc and before starting your desktop environment.

/usr/bin/dunst &

Config file

Create the conventional directory

mkdir ~/.config/dunst

Copy the default config file

The default config file is functionnal, you can adjust values to fit colors, size…

cp /usr/share/dunst/dunstrc ~/.config/dunst

YubiKey touch detector configuration

Config file

Create the conventional directory

mkdir ~/.config/yubikey-touch-detector

Fill the config file

Copy the following snippet into ~/.config/yubikey-touch-detector/service.conf. By doing this you enable the tool to use libnotify to send notifications.


Manage the service and socket

Reload the systemd manager configuration

systemctl --user daemon-reload

Enable and start the service and socket

The --user flag allows you to talk to the service manager with the calling user, rather than the service manager of the system.

systemctl --user enable --now yubikey-touch-detector.service
systemctl --user enable --now yubikey-touch-detector.socket

Check that things are up and running

systemctl --user status yubikey-touch-detector.service
yubikey-touch-detector.service - Detects when your YubiKey is waiting for a touch
systemctl --user status yubikey-touch-detector.socket
yubikey-touch-detector.socket - Unix socket activation for YubiKey touch detector service

If everything is up and running, you did it well!