You are not logged in.

#1 2012-10-06 00:03:13

stefanwilkens
Member
From: Enschede, the Netherlands
Registered: 2008-12-10
Posts: 624

Systemd and XMMS2 - Is this how it's done?

*edit* - oh damnit, wrong forum. Move please? - thanks jason
---

I've been trying to convert XMMS2's daemon to a systemd service file while still being able to use the current /etc/conf.d/xmms2d.conf.

The issue here is that xmms2's daemon needs to be run as the user and does not have a feature to drop to a user after starting (like mpd). So we must tell systemd to run this daemon as a certain user. Important to note is that is it not possible to pass a $VAR from EnvironmentFile to User=. We can pass $VAR to ExecStart=, which is what the second option relies on.

After some digging and hanging in #systemd, I've come up with 2 options:

1. using an instanced service.
/lib/systemd/system/xmms2d@.service

The service has to be started by doing systemctl start xmms2d@<username>.service.

<username> is then available in xmms2d.service as %I.

[Unit]
Description=XMMS2 daemon
After=sound.target

[Service]
Type=forking
User=%I
EnvironmentFile=/etc/conf.d/xmms2d.conf

ExecStart=/usr/bin/xmms2-launcher $XMMS2_PARAMETERS
ExecStop=/usr/bin/xmms2 quit

[Install]
WantedBy=multi-user.target

2. using /bin/su -c (aka "ugly terrible hack according to #systemd)
/lib/systemd/system/xmms2d.service

[Unit]
Description=XMMS2 daemon
After=sound.target

[Service]
Type=forking
EnvironmentFile=/etc/conf.d/xmms2d.conf

ExecStart=/bin/su $XMMS2DUSER -l -c "/usr/bin/xmms2-launcher"
ExecStop=/usr/bin/xmms2 quit

[Install]
WantedBy=multi-user.target

So now the question: Am I doing this the right way?

With gnome 3.6 around the corner, I'm trying to learn how to use systemd properly. All comments welcome smile

Last edited by stefanwilkens (2012-10-06 00:42:52)


Arch i686 on Phenom X4 | GTX760

Offline

#2 2012-10-06 00:19:36

jasonwryan
Forum & Wiki Admin
From: .nz
Registered: 2009-05-09
Posts: 19,364
Website

Re: Systemd and XMMS2 - Is this how it's done?

Multimedia here we come...


Arch + dwm   •   Mercurial repos  •   Github

Registered Linux User #482438

Offline

#3 2012-10-06 00:22:16

stefanwilkens
Member
From: Enschede, the Netherlands
Registered: 2008-12-10
Posts: 624

Re: Systemd and XMMS2 - Is this how it's done?

jasonwryan wrote:

Multimedia here we come...

Thank you, jasonwryan, brain not working properly today.


Arch i686 on Phenom X4 | GTX760

Offline

Board footer

Powered by FluxBB