There are programs that I want to automatically start after a successful graphical desktop login (e.g. to Gnome or Xmonad) and stop when I logout. How can I change the ~/.config/systemd/user/synergys.service file to do the above properly?

Right now with the service enabled, according to journalctl --user, the service tries to start when I login but fails with


which I think basically means it failed to get a display. When I manually start it after logging in, it's fine. I suspect the service is starting too early, before there's a display, because WantedBy=default.target is not specific to a GUI login and even a text login will trigger it.

I've experimented with graphical-session.target but that went nowhere. This is on Ubuntu 20.04.

Description=Synergy Server

ExecStart=/usr/bin/synergys --no-daemon --no-tray --address :: --serial-key XXXX --enable-crypto


I know I can manually run the program as a desktop session 'startup' program, but this way does not provide automatic retry upon failure.

  • Can you explain how you experimented with graphical-session.target? Was it PartOf=graphical-session.target? How did it fail? – AdminBee May 7 '20 at 8:11
  • I added PartOf=graphical-session.target under [Unit] and removed [Install]. This worked for a Gnome login session but not for an xmonad login session, where the service did not start. systemctl --user list-units --type target shows a graphical-session.target under Gnome but not under xmonad. I'm looking for a way that works for different types of sessions and I don't know how graphical-session.target works. These sessions are started from lightdm. – Syncopated May 13 '20 at 11:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.