You are not logged in.

#1 2022-01-04 03:55:10

JessicaJill
Member
Registered: 2022-01-04
Posts: 20

systemctl --user service to start on boot

Im attempting to move away from dex and using systemd as an alternative to autostart my apps.
See the recommendation here: https://github.com/jceb/dex

My first attempt wasnt a complete failure, as I can get the daemon to start manually when I issue the command

$ systemctl --user start autostart.target

Unfortunately, I want this to automagically start on boot.  If possible I would like to do it without adding another line in rc.lua

my service file is as follows:

[Unit]
Description=Package Update Notifier
After=user@1000.service

[Service]
ExecStart=/bin/bash -c "GDK_BACKEND=x11 pamac-tray"
Restart=always

Any thoughts you have is appreciated.

Offline

#2 2022-01-04 04:29:59

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,456
Website

Re: systemctl --user service to start on boot

JessicaJill wrote:

I want this to automagically start on boot.

I assume you mean when the user logs in as a user service will never run on boot.

But in any case, running X clients as user services is tricky at best - there is some guidance here, but the specifics will depend on how you start X.  I gather from the mention of rc.lua that you are using awesomewm - do you start this via xinit/startx?  Are these run from a tty, a DM, or as a user service?


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#3 2022-01-04 04:47:11

JessicaJill
Member
Registered: 2022-01-04
Posts: 20

Re: systemctl --user service to start on boot

Trilby wrote:

I assume you mean when the user logs in as a user service will never run on boot.

Correct.

Trilby wrote:

But in any case, running X clients as user services is tricky at best - there is some guidance here, but the specifics will depend on how you start X.  I gather from the mention of rc.lua that you are using awesomewm - do you start this via xinit/startx?  Are these run from a tty, a DM, or as a user service?

Admittedly, I haven't read the link you posted yet.  Its late, but I promise to read it tomorrow morning.

Yes, Im running awesomewm (because it forces me to learn things like this) via lightdm but these specific things are being run as a user service.

systemctl --user add-wants autostart.target  redshift.service
systemctl --user start autostart.target

If you believe there is a better way to approach the auto start-up these apps, Im more than willing to try.

Offline

#4 2022-01-04 05:05:14

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,456
Website

Re: systemctl --user service to start on boot

Why are you using autostart.target?  Redshift's service file is set up to wait for the display manager if you are using one and it is doing what it's supposed to.  You are using lightDM which meets the first criteria - as for the second, I never really expect DMs to do what they are supposed to.

That said, if you're using a DM, it should read xprofile which seems to me to be a far far cleaner, simpler, and reliable method of starting programs for your graphical session than any of the desktop autostart systems or (ab)using systemd user services.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#5 2022-01-04 08:24:12

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,104

Re: systemctl --user service to start on boot

While trilbys concerns are valid, you haven't done anything to "enable" the service which is what will allow the on boot/on login logic. You can remove your wants, that user services are started after the user bus is set up is implied by what they are and you need to add an install section depending on the default.target, as you are indeed using a DM this should inherit all the relevant xorg variables. So your service file should add a

[Install]
WantedBy=default.target

and then you need to just do a

systemctl --user enable $yourservicename

there's not really much point to defining a custom target here. Additionally you probably don't want to start bash because then the process you are actually running is intransparent again but instead set these relevant additional environments as part of the service where they belong to, so to sum it up your service should look like

[Unit]
Description=Package Update Notifier

[Service]
Environment="GDK_BACKEND=x11"
ExecStart=/bin/pamac-tray"
Restart=always

[Install]
WantedBy=default.target

Maybe read https://wiki.archlinux.org/title/Systemd/User instead of trying to adapt some specific utilities special tooling to a normal service.

As this is explicitly a User service question and thus runs afoul of the current forum scope I'll move this to the NC.

Last edited by V1del (2022-01-04 08:37:20)

Offline

#6 2022-01-04 12:50:17

JessicaJill
Member
Registered: 2022-01-04
Posts: 20

Re: systemctl --user service to start on boot

Thank you so much for your help, perhaps I should take a step back and explain some things further.

The reason why Im doing this is because nothing auto starts after the user logs in. 
This is why I started using dex then autostart.  So now I have to assume, because a tiling wm is so new to me and so much needs to be setup in comparison to other wms, I thought this was something I needed to implement.  Instead it seems like its a problem that I should be troubleshooting.

(This is why Ive given examples such as redshift, GDK_BACKEND=x11, etc)

Right now I dont have .xprofile .profile or /etc/xprofile.... so.... yeah... perhaps this whole attempt is an exercise in futility.

Again, thank you guys for helping me thought this

Last edited by JessicaJill (2022-01-04 13:09:41)

Offline

#7 2022-01-04 14:31:09

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 74,307

Offline

#8 2022-01-04 14:37:52

JessicaJill
Member
Registered: 2022-01-04
Posts: 20

Re: systemctl --user service to start on boot

Thank you...
I did read those and to quote the first link you sent

'dex --environment Awesome --autostart --search-paths "$XDG_CONFIG_DIRS/autostart:$XDG_CONFIG_HOME/autostart"' -- [url]https://github.com/jceb/dex[/url] 

This is basically what I quoted in my first thread and reading further, if you open https://github.com/jceb/dex you will see where he says, "I consider systemd/user as a good alternative for dex's autostart functionality and switched to it recently. In particular, systemd solves the issue of dex losing control over the started processes which causes processes to live longer than the X session which could cause additional annoyances like reboots taking a lot of time because the system is waiting for the processes to terminate."

So now it feels like we have come full circle and were back to the beginning.

Offline

#9 2022-01-04 14:54:23

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 74,307

Re: systemctl --user service to start on boot

There're multiple ways to autostat stuff w/ a session which are all acceptable. dex is only one of them being mentioned even for awesome.
The approach in the dex github frankly seems overly cumbersome, and even if you add all the name-required services to match dex created .desktop services, you'll still have to add "systemctl --user start autostart.target" to your awesome start script in order to trigger their execution.

If you want a certain service to start w/ your session using system rather than xdg, see https://wiki.archlinux.org/title/Systemd/User and simply enable it as user service.

Offline

#10 2022-01-04 15:01:20

JessicaJill
Member
Registered: 2022-01-04
Posts: 20

Re: systemctl --user service to start on boot

Looks like I have a lot more reading to do, thanks.

Offline

Board footer

Powered by FluxBB