You are not logged in.
I want to start a few GUI programs as systemd user service files, instead of my current way by using my window manger's (Openbox's) autostart file.
The Wiki article mentions that the DISPLAY and XAUTHORITY environment variables have to be set. It mentions the 50-systemd-user.sh script which is supposed to set those variables for my user session. I checked the output of systemctl --user show-environment and it is indeed set:
$ systemctl --user show-environment
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
DISPLAY=:0
HOME=/home/dino
JOURNAL_STREAM=8:19758
LANG=en_US.UTF-8
LOGNAME=dino
MAIL=/var/spool/mail/dino
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
SHELL=/bin/bash
USER=dino
XAUTHORITY=/home/dino/.Xauthority
XDG_RUNTIME_DIR=/run/user/1000None of the programs are however starting via the service files. Here's the output I get after enabling tint2's service and logging in:
● tint2.service - Taskbar and Systray
Loaded: loaded (/etc/systemd/user/tint2.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sub 2016-10-01 13:28:50 CEST; 8min ago
Process: 814 ExecStart=/usr/bin/tint2 (code=exited, status=1/FAILURE)
Main PID: 814 (code=exited, status=1/FAILURE)
Okt 01 13:28:49 masina-l systemd[798]: Started Taskbar and Systray.
Okt 01 13:28:50 masina-l systemd[798]: tint2.service: Main process exited, code=exited, status=1/FAILURE
Okt 01 13:28:50 masina-l systemd[798]: tint2.service: Unit entered failed state.
Okt 01 13:28:50 masina-l systemd[798]: tint2.service: Failed with result 'exit-code'.When I try to start tint2 via an user service after logging in manually, it works (by doing systemctl --user start tint2).
I have tried other ways to export the DISPLAY variable mentioned on the Wiki page. Using "DefaultEnvironment" in /etc/systemd/user.conf didn't work; the variable was exported, but the program refused to start. I managed to get it to work by using the "Environment=" option directly inside the service file.
Why did none of the other methods work, despite apparently doing what they were supposed to? I guess I could just add the DISPLAY variable to every service file, but that seems like a hacky way, when the other ways are supposed to achieve exactly the same, but way "cleaner" and more conveniently.
Last edited by justasug (2016-10-01 14:54:24)
Offline
This has been discussed multiple times before. You need to make sure these programs start after the X server (and after 50-systemd-user.sh has been executed), for example by introducing an "X" target (tying the services to this target instead of default.target) and starting this X target in your X or Openbox startup scripts.
Offline
Thank you, that's enough to get me started on the solution.
Offline