XDG_* environment variables don't end up in the environment of processes started by dbus-daemon or systemd
Some people set XDG_CACHE_HOME
(for example) to a location other than ~/.cache
. On a system where the systemd user session is started by PAM when the user logs in, that systemd process won't know about any of the XDG_*
env vars. If some services like tumblerd
or xfce4-notifyd
are started via systemd, they will not know about the settings of these variables.
Even if those services are started by DBus activation, if the dbus-daemon session bus process is started by the systemd user session (instead of in the Xfce startup scripts), dbus-daemon won't have those environment variables, and will start these services without them.
One possible solution is by using the systemctl import-environment
command (presumably in our xinitrc
script) to ask systemd to import a list of env vars that we specify. Then those env vars will be passed on to services systemd starts.
This still doesn't completely solve the problem of DBus activation: presumably dbus-daemon will have already been started by systemd before our startup script runs. However, DBus activation does support associating a systemd unit with the activation, and will (instead of starting the service directly) instead start the systemd unit; this would solve that problem.
So to summarize, I think we should do two things:
- In our
xinitrc
script, after setting up the variousXDG_
variables (as well asDESKTOP_SESSION
, I guess), we should runsystemctl import-environment $LIST_OF_VARS
. - We should ensure all our services that support DBus activation also include the
SystemdService
key to point to a systemd unit that can be used to start the service, and those services will need to ship systemd unit files as well, if they aren't already).
This won't be perfect: any third-party app that relies on DBus activation, and does not provide a systemd unit file, will not benefit from this fix. (Edit: looks like there's dbus-update-activation-environment
for this, which also updates systemd's env vars when passed the --systemd
option) And there's still the potential problem of any service that gets started by systemd before our xinitrc
script runs. But hopefully this should fix up at least some of the issues.
Edit^2: Hm, seems like passing no, it does, looks like we just didn't properly --systemd
to dbus-update-activation-environment
doesn't actually work. I guess we can just call both programs.export
something in our startup script...