I've got a program called redshift that I would like to autostart when I log in. If I run "redshift" in a terminal (or redshift &) or via alt+f2, this will start it. I don't think it has an init script, so will adding "redshift" to my .profile file make it load at start? I suppose a cronjob set to @reboot could also work?

I think some programs need to be executed from a certain user environment, especially those affecting graphical elements? For example, if I SSH to a remote machine and try to open up a GUI program, obviously this will not be possible so it will fail. That's what I am trying to avoid in regards to where I execute this program from.

  • Do you mean to run it every time you login? Or at boot? How about ssh sessions, should the program start if you remotely login into your pc? If you are already logged in and open a new terminal, shoudl the program run again? Which distro are you on? Feb 7, 2014 at 6:40
  • Whether it happens at boot or whether it happens when I login doesn't matter. I just want it to run whenever I start using my computer. Currently running Debian. And no, when I open a terminal, it should not run. This program should ideally start before I ever open a terminal (that was just an idea).
    – Peter
    Feb 7, 2014 at 6:48

1 Answer 1


redshift is not a system service; it works within your login session, as it needs to access the X11 server. So basically it should be autostarted the same way most graphical programs are:

Method 1

Add a file redshift.desktop to the XDG Autostart directory, ~/.config/autostart/:

[Desktop Entry]

This works with desktop environments that follow the XDG Autostart spec; this includes GNOME, KDE, Xfce, and many others. In some, it is editable through graphical interfaces (e.g. gnome-session-properties in GNOME).

Method 2

Add the following line...

redshift &

...to your ~/.xprofile. This works with most display managers (gdm, kdm, lightdm, lxdm, sddm – not slim, however).

If you use the startx tool, ~/.xprofile is not used by default, so you'll have to update your ~/.xinitrc script instead – add the same line somewhere before starting the session manager.

Method 3

If you use a display manager like GDM, you might want to run the program before logging in, so that it'd apply to the login screen as well. How to do this varies between display managers, but in GDM it can be done by editing /etc/gdm/Init/Default. (Disclaimer: I haven't tried and this might be the wrong file.)

Things that will not work

  • A system init script will not work since it runs independently of graphical sessions – it won't have the right $DISPLAY nor the right $XAUTHORITY set; if you hardcode those, it might end up trying to connect to the wrong display (e.g. you hardcode DISPLAY=":0" but your session happens to start at :1); and if you make it try all displays, the script is still very likely to start before any X11 display has been started.

  • A @reboot cronjob will run as the right user (rather than needing to su/sudo), but otherwise it has all the same problems as system init scripts.

  • Alright, it looks like options 1 and 2 don't work and I don't know if I should try 3. I am running i3 which is a tiling window manager and not a common desktop manager.
    – Peter
    Feb 14, 2014 at 0:00
  • Option 2 should certainly work, then.
    – user1686
    Feb 14, 2014 at 20:53
  • Option 1 worked a treat, thank you! Ubuntu 18.04. Jul 10, 2020 at 5:39

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.