You are not logged in.

#1 2018-08-18 13:37:20

jlosito
Member
From: New Jersey, USA
Registered: 2018-08-18
Posts: 3

autostart vs systemctl --user

I've been messing around with redshift and have been following the wiki below which discusses the configuring the application.

https://wiki.archlinux.org/index.php/redshift

In the autostart section of the wiki, it touches upon different ways one can automatically start the application. As of right now, I've been using the autostart method by placing a redshift.desktop file in ~/.config/autostart that I have created, but I'm curios about other ways one can achieve the same outcome. While I've had experience with systemd, I'm fairly new to services which can be controlled by individual users rather than requiring administrative permissions. In other words, using the systemctl --user variant of the command and its associated service files in ~/.config/systemd/user. More about the later topic can be found in the following wiki.

https://wiki.archlinux.org/index.php/Systemd/User

My question is the following. What are the pros and cons of using systemd compared to autostart, and what are some scenarios one should use one over the other.

From my understand thus far, autostart is dependent on the desktop environment one is using. I could be wrong. If I am, please correct me. Thus, if one is not using a desktop environment such as Gnome or KDE, redshift will not start automatically even though it is possible that the application can still regulate the display without a desktop environment. I could be wrong about this as well. Moreover, if one wants to stop the application, one would need to find the PID of the instance that the individual user started. Systemd on the other hand would provide more flexibility due to the lack of dependency on a desktop environment and a more convient way of starting and stopping the application. Are my statements correct?

Offline

#2 2018-08-18 13:48:52

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 19,950
Website

Re: autostart vs systemctl --user

Your description sounds correct.  One could use the autostart folder without a full DE: you just need some process that reads through the .desktop files and starts them up.  But this process is provided by default by the big DEs and not by WMs.

I doubt there is any difference in efficiency/performance.  So just use the one that is more comfortable for you.

One other difference to consider, though, is that the autostart .desktop files are specifically for processes to run within an X session while systemd --user services are for anytime the user is logged in.  For the systemd service you will need to take care to ensure DISPLAY is in the environment and that the service either checks for X running and/or fails gracefully if it isn't.  You don't want some background process continually trying and failing to start redshift every time you log into a tty (if you ever do).  There are, of course, ways to do this well with systemd.services, but it is just one more check that is needed.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2018-08-18 16:56:12

jlosito
Member
From: New Jersey, USA
Registered: 2018-08-18
Posts: 3

Re: autostart vs systemctl --user

As far as my knowledge goes, I believe redshift relies on X11, but let us assume that in the future the application can also support Wayland. Are you saying that the autostart functionality would be useless because of autostart being associated with X11? Thus, using a service file would provide more flexibility due to its ability to work with both X11 and Wayland without considering the fact that one will need to take care of DISPLAY, or is there an equivalent of autostart associated with Wayland?

In this case, what would you rather use?

Offline

#4 2018-08-18 18:44:22

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 19,950
Website

Re: autostart vs systemctl --user

jlosito wrote:

... or is there an equivalent of autostart associated with Wayland?

I don't know much about wayland.  But I'm pretty sure for the sake of this discussion X and Wayland can be treated synomymously as autostarting desktop files is not a function of X or Wayland, but of the DE's that run on them.  For example, I'm pretty sure gnome on wayland uses desktop files just like gnome on X11 does.

My distinction wasn't intended to be X vs other display servers, but rather graphical sessions vs tty.  Systemd --user services are (by default) tied to user log in, not a display server start up.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#5 2018-08-19 01:07:25

jlosito
Member
From: New Jersey, USA
Registered: 2018-08-18
Posts: 3

Re: autostart vs systemctl --user

Thanks for your input. It was very insightful.

Offline

#6 2018-08-19 01:19:16

Steef435
Member
Registered: 2013-08-29
Posts: 521
Website

Re: autostart vs systemctl --user

The service provided with redshift contains After=display-manager.service, so if you do not use a display manager, this won't work as-is (Trilby explained this already). I think that in the end it comes down to taste: do you want your init system to influence X, or your DE? I myself start redshift in my .xinitrc. (and then use killall if I want to get rid of it). I think that is the most logical place to put it. (EDIT: or in your xprofile or whatever, if you don't use startx)

Last edited by Steef435 (2018-08-19 01:21:11)

Offline

#7 2018-08-19 01:46:07

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 19,950
Website

Re: autostart vs systemctl --user

I'd also put anything X (or wayland/graphical) related in an xinitrc or similar place.  But I do use systemd --user services for mbysnc (synchronizing email) and other tasks that have no dependence on a graphical interface.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

Board footer

Powered by FluxBB