redshift-gtk segfault when using systemd enabled · Issue #265 · jonls/redshift

The crash seems to happen because the DISPLAY environment variable is initially undefined in the user manager environment when redshift-gtk.service is started after login.

systemd uses a special xinitrc.dscript to import DISPLAY later on: https://github.com/systemd/systemd/blob/master/xorg/50-systemd-user.sh, but redshift-gtk.service doesn't wait for that.

There is a special systemd target named graphical-session.target (documentation). Looks like redshift-gtk.service should have a relation to this target. According to documentation, this code in redshift-gtk.service:

[Install]
WantedBy=default.target

should be changed to

[Install]
WantedBy=graphical-session.target

However, there needs to be support for graphical-session.target in the desktop environment. If the DE doesn't know about this target, the target and redshift-gtk.service won't be activated at all. For example, on my Xfce desktop:

> systemctl --user status graphical-session.target
● graphical-session.target - Current graphical user session
   Loaded: loaded (/usr/lib/systemd/user/graphical-session.target; static; vendor preset: enabled)
   Active: inactive (dead)
     Docs: man:systemd.special(7)

In such cases it may be possible to create a custom target unit that BindsTo=graphical-session.target and then start this unit manually in the Session and Startup dialog.