You are not logged in.

#1 2016-12-02 15:36:32

occasionally_smart
Member
Registered: 2016-12-02
Posts: 21

[solved] getting mpd to autodetect my mpd.conf

Hey!

I somewhat ran against a wall trying to set up my mpd and I'd like to ask for some help.

At first I tried setting it up globally with my configuration file being /etc/mpd.conf. I then ran into issues since mpd couldn't "see" my music files (located in ~/music). I read the article in the wiki and came across this line:
"MPD needs to have +x permissions on all parent directories to the music collection and also read access to all directories containing music files. This conflicts with the default configuration of the user directory where many users store their music."
I figured that may be my issue and one of the recommended solutions was to just configure it locally.

I deleted my previous configuration file /etc/mpd.conf and set a new one up in ~/.config/mpd/mpd.conf and it kinda works.
systemctl status mpd.service shows that mpd doesn't find a configuration file, but if i manually type "mpd ~/.config/mpd/mpd.conf" in the terminal everything works perfectly fine.
Not sure if it even made sense but I already tried disabling and reenabling my mpd.service.

Thanks in advance!

Last edited by occasionally_smart (2016-12-02 16:10:48)

Offline

#2 2016-12-02 16:01:55

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

Re: [solved] getting mpd to autodetect my mpd.conf

The way you run mpd (with the system instance of systemd), mpd runs as the `mpd` user, so it doesn't access your personal configuration file.

I would suggest that you run mpd as a systemd user service instead. You can essentially copy the global mpd.service (from /usr/lib/systemd/system) into your $XDG_CONFIG_HOME/systemd/user, then start it with:

systemctl --user start mpd.service

This will run mpd as your user (and as you have already noticed, mpd then reads your $XDG_CONFIG_HOME/mpd/mpd.conf).


pkgshackscfgblag

Offline

#3 2016-12-02 16:10:26

occasionally_smart
Member
Registered: 2016-12-02
Posts: 21

Re: [solved] getting mpd to autodetect my mpd.conf

that did the trick - thank you very much!

Offline

#4 2016-12-14 13:41:56

firekage
Member
From: Eastern Europe, Poland
Registered: 2013-06-30
Posts: 617

Re: [solved] getting mpd to autodetect my mpd.conf

ayekat wrote:

The way you run mpd (with the system instance of systemd), mpd runs as the `mpd` user, so it doesn't access your personal configuration file.

I would suggest that you run mpd as a systemd user service instead. You can essentially copy the global mpd.service (from /usr/lib/systemd/system) into your $XDG_CONFIG_HOME/systemd/user, then start it with:

systemctl --user start mpd.service

This will run mpd as your user (and as you have already noticed, mpd then reads your $XDG_CONFIG_HOME/mpd/mpd.conf).


Sorry for refreshing but i have similar question. In Arch Wiki mpd section there is written this:

The package mpd provides user service file in /usr/lib/systemd/user/mpd.service. The configuration file is expected to exist either in ~/.mpdconf or ~/.config/mpd/mpd.conf, see systemd#Editing provided units if you would like to use different path. The process is not started as root, so you should not use the user and group variables in the MPD configuration file, the process already has user permissions and therefore it is not necessary to change them further.

All you have to do is enable and start the mpd user service[broken link: invalid section].

Note:
mpd provides also system service file in /usr/lib/systemd/system/mpd.service, but as the process is started as root, it does not read the user configuration file and falls back to /etc/mpd.conf. Global configuration is described in other section.
Make sure to disable every other method of starting mpd you used before.

After several last updates there is something wrong with mpd.

First one:
-there is no /usr/lib/systemd/user/mpd.service file at all
Second :
-i have created mpd for user, not root user and after updates each time from boot i cant connect to mpd. I have manually input mpd ~/.config/mpd/mpd.conf and only after that mpd starts
Third:
- i cant start user service with systemctl --user enable/start mpd.service because there is no user service file

Could somebody tell me what went wrong?

Offline

#5 2016-12-14 14:10:23

seth
Member
Registered: 2012-09-03
Posts: 51,213

Re: [solved] getting mpd to autodetect my mpd.conf

/usr/lib/systemd/user/mpd.service is provided by the "mpd" package - you either don't have it installed or the installation is broken, so query pacman (and its logs) about what's wrong.
Ensure to have a sane package installation and see which of your trouble remains.
Also this is OT, so rather open a new ticket than adding fuzz to a "sloved" one.

Offline

#6 2016-12-14 14:33:17

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

Re: [solved] getting mpd to autodetect my mpd.conf

What a coincidence! Apparently, /usr/lib/systemd/user/mpd.service is about to disappear in the next mpd package release. So either you've grabbed a really fresh version of mpd for some reason, or seth is right and you simply have not installed mpd.

In the end, I repeat my original suggestion to copy /usr/lib/systemd/system/mpd.service into your $XDG_CONFIG_HOME/systemd/user. You'll need to adapt a few things, though (like removing the `User` line, and perhaps adapting the path to your mpd config if necessary, and maybe remove some of the security settings that won't apply correctly in a user environment).

Last edited by ayekat (2016-12-14 14:35:20)


pkgshackscfgblag

Offline

#7 2016-12-14 14:53:52

seth
Member
Registered: 2012-09-03
Posts: 51,213

Re: [solved] getting mpd to autodetect my mpd.conf

If he's got a such recent patchlevel, the user service will fail (according to the bug, yesno?)
In case, just do what was done before systemd and simply run the daemon as user with the first login (and fork it)  - if you want to run it as user.

Offline

#8 2016-12-14 14:58:27

WorMzy
Forum Moderator
From: Scotland
Registered: 2010-06-16
Posts: 11,860
Website

Re: [solved] getting mpd to autodetect my mpd.conf

ayekat wrote:

What a coincidence! Apparently, /usr/lib/systemd/user/mpd.service is about to disappear in the next mpd package release.

Not "about to" it's already gone. tongue

From the bug report upstream, there may be an official user service in the works, but the system service isn't designed to be used that way, mileage may vary.


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Offline

#9 2016-12-14 15:09:00

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

Re: [solved] getting mpd to autodetect my mpd.conf

WorMzy wrote:

Not "about to" it's already gone. tongue

B-but... according to pacman, I'm running the latest package (0.19.21-1) and it still provides /usr/lib/systemd/user/mpd.service. And the linked PKGBUILD patch introduces 0.19.21-2, so... - I'm a bit confused now.

EDIT Thanks for the answer, Scimmia! ↓
EDIT-2 AAAH! Now I see that the patch was for 0.19.20-2. I'm sorry for all the confusion.

From the bug report upstream, there may be an official user service in the works, but the system service isn't designed to be used that way, mileage may vary.

I guess I was a little too focused on handling as much as possible on a user-level (for managing dotfiles, etc.) that I forgot that some services (like mpd) are indeed not meant to run multiple times on the same system. Thanks for showing me the light tongue

I am not sure what the most elegant way to solve this would be, though (probably create a separate `mpd` user who manages the music data on its own, so that its "user-agnostic"?)
But this is probably off-topic now.

Last edited by ayekat (2016-12-14 15:30:49)


pkgshackscfgblag

Offline

#10 2016-12-14 15:12:23

Scimmia
Fellow
Registered: 2012-09-01
Posts: 11,559

Re: [solved] getting mpd to autodetect my mpd.conf

Looks like upstream is including a user unit now. It was removed with 0.19.20-2, but 0.19.21-1 brought it back from upstream.

Offline

#11 2016-12-14 15:23:38

WorMzy
Forum Moderator
From: Scotland
Registered: 2010-06-16
Posts: 11,860
Website

Re: [solved] getting mpd to autodetect my mpd.conf

Thanks for clearing that up, Scimmia.

So for anyone still confused, the user service in version 0.19.21-1 is from upstream, and will likely be around for the foreseeable future.


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Offline

#12 2016-12-14 15:51:08

firekage
Member
From: Eastern Europe, Poland
Registered: 2013-06-30
Posts: 617

Re: [solved] getting mpd to autodetect my mpd.conf

Scimmia wrote:

Looks like upstream is including a user unit now. It was removed with 0.19.20-2, but 0.19.21-1 brought it back from upstream.


Now it works!

I understand that this user service file wont be removed? I configured mpd to run not as a root, not as a "mpd" user but my own account name.

Offline

Board footer

Powered by FluxBB