Sunday, May 26, 2019

systemd unit to start a browser/user process on network up

It took me far too long to get this script right. The gottchas:
  1. User units cannot reference or interact with system units.
  2. On my system at least I needed to specifically enable systemd-networkd-wait-online.service to have work.
  3. To enable pulse audio from a system process you need to
    1. set XDG_RUNTIME_DIR, which
    2. needs uid, not user name.
Description=Start Firefox



I haven't looked into using this unit as a template as I'm not sure how to translate the user name into uid for the XDG_RUNTIME_DIR variable. It's a real shame we can't run it as a user process else we'd be able to use %u and %U.


Kai Hendry said...

Something to be said for the humble .xinitrc file.

Jamie said...

And that's where I used to have it, but now parallel boot is so fast that the network comes up after Firefox and none of my saved tabs load. Hence the need for a systemd unit to fire after network.