You are not logged in.

#1 2017-05-30 20:31:23

arvind
Member
Registered: 2012-10-03
Posts: 11

Start service as user when logging in

I use pulseaudio-dlna (from AUR), a program that creates a pulseaudio sink to stream sound to a DLNA server. This needs to be run as a user. I can start it perfectly fine from the command line:

pulseaudio-dlna

I don't want to run it from the command line every time I need it. I saw that systemd has the option to run a program as a user, when that user logs in for the first time. See https://wiki.archlinux.org/index.php/Systemd/User. Note that for me, logging in means logging into Xfce with lightdm. So I created a service file:

[Unit]
Description=Pulseaudio DLNA

[Service]
ExecStart=/usr/bin/pulseaudio-dlna

[Install]
WantedBy=multi-user.target

Now I can start my service from a terminal in Xfce:

systemctl --user start pulseaudio-dlna

I enabled my service, assuming that this would start it when I log on to X:

systemctl --user enable pulseaudio-dlna

But after logging in, nothing happens. Then I thought, let's do it the ugly way. So in the Autostart settings of Xfce, I now added the line

systemctl --user start pulseaudio-dlna

This still doesn't work, because now the service does start, but crashes because for some reason it cannot find the ip-address of the host (my computer). I can supply that as a parameter but that also doesn't work because it cannot find the network. But at this point I feel I'm digressing too much. Does anyone have an idea why it doesn't start when I log in to X?

Offline

#2 2017-05-30 20:38:13

ayekat
Member
Registered: 2011-01-17
Posts: 1,634

Re: Start service as user when logging in

arvind wrote:
[Install]
WantedBy=multi-user.target

Unfortunately I can't help for the "missing IP address" issue—but for user services, the only target appears to be default.target, so you might need to change that.


pkgs │ hacks │ cfg │ blag

Offline

#3 2017-05-30 20:54:07

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 78,346

Re: Start service as user when logging in

Requires=network.target
After=network.target

Otherwise maybe paste the actual error messages about the missing IP/network.
Also the setup where you run the service shown in #1 as user service from XFCE autostart is rather detouring - you could just run the command directly.

Online

Board footer

Powered by FluxBB