It took me far too long to get this script right. The gottchas:
I haven't looked into using this unit as a template as I'm not sure how to translate the user name into
- User units cannot reference or interact with system units.
- On my system at least I needed to specifically enable
systemd-networkd-wait-online.service
to havenetwork-online.target
work. - To enable pulse audio from a system process you need to
- set
XDG_RUNTIME_DIR
, which - needs
uid
, not user name.
- set
[Unit]
Description=Start Firefox
Wants=network-online.target
After=network-online.target
[Service]
User=[USER]
Environment="DISPLAY=:0"
Environment="XAUTHORITY=/home/[USER]/.Xauthority"
Environment="XDG_RUNTIME_DIR=/run/user/[UID]"
ExecStart=/usr/bin/firefox
[Install]
WantedBy=multi-user.target
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
.
Something to be said for the humble .xinitrc file.
ReplyDeletehttps://github.com/kaihendry/dotfiles/blob/master/.xinitrc#L47
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.
ReplyDelete