eonpatapon / mpDris2

MPRIS V2.1 support for mpd

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[question] Start multiple instances of mpdris

Fuco1 opened this issue · comments

I currently use two mpd servers, one locally and one on a raspberry pi. I would like to be able to start two mpdris instances to control one or the other. Right now the older instance is replaced when I start another one.

This should now work in git – specify a custom service name for the 2nd instance, e.g.

[Connection]
host = …
bus_name = org.mpris.MediaPlayer2.mpd-rpi

(There is also a --bus-name= option. The bus name must be org.mpris.MediaPlayer2.<something>.)

Damn @grawity that was fast! I'm not sure I follow with the config though. I'm not using systemd at this computer (it's an oldish linux mint ditro)

I have this in ~/.config/mpDris2/mpDris2.conf

[Connection]
host = localhost
port = 6600
password =
music_dir = /home/matus/media/music

[Connection]
host = 192.168.10.20
port = 6600
password =
bus_name=org.mpris.MediaPlayer2.mpd-rpi

[Bling]
mmkeys = False
notify = False

Is this how I should configure multiple connections?

Nevermind, I botched the installation. I see 0.7 now has the -c option.

So I split the config into two, when I run the second instance I get this

[23:02:10]matus@herakleitos:/usr/local/stow
> mpDris2 -c ~/.config/mpDris2/rpi.conf
Traceback (most recent call last):
  File "/usr/local/bin/mpDris2", line 1275, in <module>
    config.read_file(fh)
AttributeError: SafeConfigParser instance has no attribute 'read_file'

What version of Python are you using? I think I'll soon declare 2.x as no longer supported...

And yes, you need one config file per instance.

I use 2.7.6. I use the system installation and have mpdris also installed system-wise. I'm not too much of a python person but I know how to use virtualenv in a basic way, would that help me somehow to run this with newer version of python?

Or... I guess I'll just put this into Docker :) I love putting things in Docker :D Would you be interested in having a docker version set up?

@grawity currently (on commit 5362867), when bus name is neither given on command line nor in a config file (e.g. when no conf file exists), mdpris crashes because the variable is initialized to None:

Traceback (most recent call last):
  File "/usr/bin/mpDris2", line 1350, in <module>
    mpd_wrapper.run()
  File "/usr/bin/mpDris2", line 289, in run
    if self.my_connect():
  File "/usr/bin/mpDris2", line 336, in my_connect
    self._dbus_service = MPRISInterface(self._params)
  File "/usr/bin/mpDris2", line 873, in __init__
    if not self._name.startswith("org.mpris.MediaPlayer2."):
AttributeError: 'NoneType' object has no attribute 'startswith'

Anyways, I can run multiple instances of mpdris in parallel with this systemd-user-unit:

[Unit]
Description=mpDris2 - Music Player Daemon D-Bus bridge (host %I)

[Service]
ExecStart=/usr/bin/mpDris2 --bus-name org.mpris.MediaPlayer2.mpd-%i  %i
BusName=org.mpris.MediaPlayer2.mpd-%i

[Install]
WantedBy=default.target

No configuration file needed.

Fixed the crash. Most distributions have separate packages for Python 2.x series and 3.x series; the 3.x mpd module might be called "python-mpd2".

This works for me so I think we can close? Thank you very much for implementing this.