You are not logged in.

#1 2015-11-09 02:37:57

Horizon_Brave
Operating System: Linux-Nettrix
Registered: 2015-10-18
Posts: 1,473

StartUp Services in Systemd vs User Config Files

Hey everyone, so in my deeper dive of systemd (it's slowing making sense, thanks to some of links that you fine folk have provided me)  I noticed that if I create a startup .service for the .graphical runlevel, I have it point to an executable script that I stashed in /lib/systemd/system. (along with all of the other unit files). The script basically kills tint2 when it's run, and makes an attempt to start two different conky files.

What I noticed is that...it didn't work lol. I later found out that I could just as easily disable tint2 from running from the .config/openbox/autostart  config file.

But this brought up the question to me, which files take precedent over others? clearly the openbox/autostart config file too precedence over the the systemd .service unit.

Just as a sanity check, I looked at dmesg and saw that the custom .service that I wrote to kill tint2, was indeed called. So what happens here? Are the unit files run first, THEN any user config files like the openbox configs run last and basically overwrite anything that the is done by systemd scripts?


Thanks in advance...


"I have not failed, I have found 10,000 ways that will not work" -Edison

Offline

#2 2015-11-09 04:22:51

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 8,327
Website

Re: StartUp Services in Systemd vs User Config Files

openbox/autostart is for things the user wants to do after they have logged in. It's just automation for things you could also have done manually. The systemd stuff happens before login and applies to the whole system, so starting conky or killing tint2 make little sense in that context - they need a user's X session to run in.

Putting .desktop files in /etc/xdg/autostart is an alternative way of starting things up in a user's session. They will apply to all users. ~/.config/autostart is an alternative place for those .desktop files, applying only to that particular user.

Installed applications often put .desktop files in /etc/xdg/autostart, but openbox/autostart is often easier for an individual to use.


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), idle Twitterings and GitStuff )

Introduction to the Bunsenlabs Lithium Desktop

Offline

#3 2015-11-09 04:40:29

Horizon_Brave
Operating System: Linux-Nettrix
Registered: 2015-10-18
Posts: 1,473

Re: StartUp Services in Systemd vs User Config Files

Thanks johnraff!  One question though, when you say the commands need an xsession to run, does that go for all commands like that? Basically any command you can run from a command line, wouldn't work in a systemd config script? Would it completely be ignored? Or does it work but it's just "forgotten" when the user's x session begins?


"I have not failed, I have found 10,000 ways that will not work" -Edison

Offline

#4 2015-11-09 05:33:00

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 8,327
Website

Re: StartUp Services in Systemd vs User Config Files

The question to ask is "who" is running the command: a logged-in user or root?
Of course not all apps need an x-session to run, but all commands need to be run by someone.


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), idle Twitterings and GitStuff )

Introduction to the Bunsenlabs Lithium Desktop

Offline

#5 2015-11-09 05:46:13

Horizon_Brave
Operating System: Linux-Nettrix
Registered: 2015-10-18
Posts: 1,473

Re: StartUp Services in Systemd vs User Config Files

hmm not sure I understand though... If the script is being used by systemd to initialize the system, no one is technically running the command right? If I have a .service unit file that points to startup script that calls conky to begin, i'm still not sure what causes the commands to just not work?


"I have not failed, I have found 10,000 ways that will not work" -Edison

Offline

#6 2015-11-09 06:33:03

gako
Member
Registered: 2015-10-02
Posts: 241

Re: StartUp Services in Systemd vs User Config Files

johnraff pointed you right in post#2. Your service file is running before your X starts (your desktop). Conky, for example needs X to run so your autostart file would be the place for that. It'd probably be more apparent to you if you were looking at the login shell instead of the login manager after boot. If you tried to start tint2 or conky from tty would it work?
You gotta think past that, err I mean before that. smile

Offline

#7 2015-11-09 07:59:26

Head_on_a_Stick
Member
From: London
Registered: 2015-09-29
Posts: 8,759
Website

Re: StartUp Services in Systemd vs User Config Files

Horizon_Brave wrote:

Just as a sanity check, I looked at dmesg and saw that the custom .service that I wrote to kill tint2, was indeed called. So what happens here? Are the unit files run first, THEN any user config files like the openbox configs run last and basically overwrite anything that the is done by systemd scripts?

There are many hooks and targets that can be used in a custom unit file.

Have you read all of systemd.unit(5)?

Post your unit file here.


“Et ignotas animum dimittit in artes.” — Ovid, Metamorphoses, VIII., 18.

Forum Rules   •   How to report a problem   •   Software that rocks

Offline

#8 2015-11-09 20:22:21

Frogman
Member
From: The Server Room
Registered: 2015-11-01
Posts: 22

Re: StartUp Services in Systemd vs User Config Files

Horizon_Brave wrote:

hmm not sure I understand though... If the script is being used by systemd to initialize the system, no one is technically running the command right? If I have a .service unit file that points to startup script that calls conky to begin, i'm still not sure what causes the commands to just not work?

Depending on what is being run it is usually either root, or a "service user". If you look at the contents of /etc/passwd, service users usually have a login shell of /bin/false or /usr/sbin/nologin in place of a shell. They also tend to have a UID of under 1000 (depends on distro, may be under 500).

Offline

Board footer

Powered by FluxBB