∂f/∂x

Triggering a systemd unit on sound card change

Fri 03 May 2024 — by dfdx

In the end this turned out simpler than I expected it to be on a systemd-based system (in my case NixOs.) Just adding a udev-rule like this did it:

SUBSYSTEM=="sound", ACTION=="change", TAG+="systemd", ENV{SYSTEMD_WANTS}+="processPriorityTuning.service"

As you can tell from the rule when it triggers it will make systemd "want" the processPriorityTuning.service. The change action is systemd specific: https://github.com/systemd/systemd/blob/main/rules.d/78-sound-card.rules