diff --git a/docs/ext/mpris.rst b/docs/ext/mpris.rst new file mode 100644 index 00000000..b1c23278 --- /dev/null +++ b/docs/ext/mpris.rst @@ -0,0 +1,70 @@ +************ +Mopidy-MPRIS +************ + +This extension lets you control Mopidy through the Media Player Remote +Interfacing Specification (`MPRIS `_) D-Bus interface. + +An example of an MPRIS client is the :ref:`ubuntu-sound-menu`. + + +Dependencies +============ + +- D-Bus Python bindings. The package is named ``python-dbus`` in + Ubuntu/Debian. + +- ``libindicate`` Python bindings is needed to expose Mopidy in e.g. the + Ubuntu Sound Menu. The package is named ``python-indicate`` in + Ubuntu/Debian. + +- An ``.desktop`` file for Mopidy installed at the path set in the + :confval:`mpris/desktop_file` config value. See :ref:`install-desktop-file` + for details. + + +Configuration values +==================== + +.. confval:: mpris/enabled + + If the MPRIS extension should be enabled or not. + +.. confval:: mpris/desktop_file + + Location of the Mopidy ``.desktop`` file. + + +Default configuration +===================== + +.. literalinclude:: ../../mopidy/frontends/mpris/ext.conf + :language: ini + + +Usage +===== + +The extension is enabled by default if all dependencies are available. + + +Testing the MPRIS API +===================== + +To test, start Mopidy, and then run the following in a Python shell:: + + import dbus + bus = dbus.SessionBus() + player = bus.get_object('org.mpris.MediaPlayer2.mopidy', + '/org/mpris/MediaPlayer2') + +Now you can control Mopidy through the player object. Examples: + +- To get some properties from Mopidy, run:: + + props = player.GetAll('org.mpris.MediaPlayer2', + dbus_interface='org.freedesktop.DBus.Properties') + +- To quit Mopidy through D-Bus, run:: + + player.Quit(dbus_interface='org.mpris.MediaPlayer2') diff --git a/docs/modules/frontends/mpris.rst b/docs/modules/frontends/mpris.rst deleted file mode 100644 index e0ec63da..00000000 --- a/docs/modules/frontends/mpris.rst +++ /dev/null @@ -1,8 +0,0 @@ -.. _mpris-frontend: - -*********************************************** -:mod:`mopidy.frontends.mpris` -- MPRIS frontend -*********************************************** - -.. automodule:: mopidy.frontends.mpris - :synopsis: MPRIS frontend diff --git a/mopidy/frontends/mpris/__init__.py b/mopidy/frontends/mpris/__init__.py index 5be9c6cf..7601d81f 100644 --- a/mopidy/frontends/mpris/__init__.py +++ b/mopidy/frontends/mpris/__init__.py @@ -4,76 +4,7 @@ import os import mopidy from mopidy import exceptions, ext -from mopidy.utils import formatting, config - - -default_config = """ -[mpris] -enabled = true -desktop_file = /usr/share/applications/mopidy.desktop -""" - -__doc__ = """ -Frontend which lets you control Mopidy through the Media Player Remote -Interfacing Specification (`MPRIS `_) D-Bus -interface. - -An example of an MPRIS client is the `Ubuntu Sound Menu -`_. - -**Dependencies** - -- D-Bus Python bindings. The package is named ``python-dbus`` in - Ubuntu/Debian. - -- ``libindicate`` Python bindings is needed to expose Mopidy in e.g. the - Ubuntu Sound Menu. The package is named ``python-indicate`` in - Ubuntu/Debian. - -- An ``.desktop`` file for Mopidy installed at the path set in the - :confval:`mpris/desktop_file` config value. See :ref:`install-desktop-file` - for details. - -**Configuration** - -.. confval:: mpris/enabled - - If the MPRIS extension should be enabled or not. - -.. confval:: mpris/desktop_file - - Location of the Mopidy ``.desktop`` file. - -**Default config** - -.. code-block:: ini - -%(config)s - -**Usage** - -The frontend is enabled by default if all dependencies are available. - -**Testing the frontend** - -To test, start Mopidy, and then run the following in a Python shell:: - - import dbus - bus = dbus.SessionBus() - player = bus.get_object('org.mpris.MediaPlayer2.mopidy', - '/org/mpris/MediaPlayer2') - -Now you can control Mopidy through the player object. Examples: - -- To get some properties from Mopidy, run:: - - props = player.GetAll('org.mpris.MediaPlayer2', - dbus_interface='org.freedesktop.DBus.Properties') - -- To quit Mopidy through D-Bus, run:: - - player.Quit(dbus_interface='org.mpris.MediaPlayer2') -""" % {'config': formatting.indent(default_config)} +from mopidy.utils import config class Extension(ext.Extension): @@ -83,7 +14,8 @@ class Extension(ext.Extension): version = mopidy.__version__ def get_default_config(self): - return default_config + conf_file = os.path.join(os.path.dirname(__file__), 'ext.conf') + return open(conf_file).read() def get_config_schema(self): schema = config.ExtensionConfigSchema() diff --git a/mopidy/frontends/mpris/ext.conf b/mopidy/frontends/mpris/ext.conf new file mode 100644 index 00000000..b83411c2 --- /dev/null +++ b/mopidy/frontends/mpris/ext.conf @@ -0,0 +1,3 @@ +[mpris] +enabled = true +desktop_file = /usr/share/applications/mopidy.desktop