eonpatapon/mpDris2 — pull request #37 by grawity (2013-01-02 17:00:39+00:00)
Title: Automatically exit when another instance is launched

When multiple mpDris instances are running, only one can hold the `org.mpris.MediaPlayer2.mpd` bus name and send signals / receive method calls.

There are several possibilities:

1. Do not queue for ownership, but fail immediately if another process owns the name. This can be achieved by just setting `do_not_queue=True` in the `dbus.service.BusName()` constructor.

2. Ask DBus to replace the old owner, and allow being replaced. Exit upon receiving the "name lost" signal.

This pull-request implements approach #2, which seems to be more useful. (Unfortunately, it is unable to replace *older* versions, but if necessary it could kill the old process by PID.)