From 771c352281d61f2603ba26c41047af2325c16803 Mon Sep 17 00:00:00 2001 From: davemds Date: Mon, 11 Nov 2013 23:40:27 +0100 Subject: [PATCH] music-control: do not request props if the service is not up. This prevent music player that support the dbus activation system to be launched at module startup. Instead of blindly request properties first check if the name has an owner. As a side effect now the module fully support the dbus activation system: if your player is not running it will be launched when you click his name or any of the controls in the popup. Note: If your player does not provide the autorun feature you can just create a .service file in dbus share folder with the following content: [D-BUS Service] Name=org.mpris.MediaPlayer2.quodlibet Exec=/usr/bin/quodlibet ...of course you must change the name of your player ;) --- src/modules/music-control/e_mod_main.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/modules/music-control/e_mod_main.c b/src/modules/music-control/e_mod_main.c index c13fc5291..335b77cdd 100644 --- a/src/modules/music-control/e_mod_main.c +++ b/src/modules/music-control/e_mod_main.c @@ -319,6 +319,25 @@ prop_changed(void *data, Eldbus_Proxy *proxy, void *event_info) } } +static void +cb_name_owner_has(void *data, const Eldbus_Message *msg, Eldbus_Pending *pending) +{ + E_Music_Control_Module_Context *ctxt = data; + Eina_Bool owner_exists; + + if (eldbus_message_error_get(msg, NULL, NULL)) + return; + if (!eldbus_message_arguments_get(msg, "b", &owner_exists)) + return; + if (owner_exists) + { + media_player2_player_playback_status_propget(ctxt->mpris2_player, + cb_playback_status_get, ctxt); + media_player2_player_metadata_propget(ctxt->mpris2_player, + cb_metadata_get, ctxt); + } +} + Eina_Bool music_control_dbus_init(E_Music_Control_Module_Context *ctxt, const char *bus) { @@ -328,10 +347,9 @@ music_control_dbus_init(E_Music_Control_Module_Context *ctxt, const char *bus) ctxt->mrpis2 = mpris_media_player2_proxy_get(ctxt->conn, bus, NULL); ctxt->mpris2_player = media_player2_player_proxy_get(ctxt->conn, bus, NULL); - media_player2_player_playback_status_propget(ctxt->mpris2_player, cb_playback_status_get, ctxt); - media_player2_player_metadata_propget(ctxt->mpris2_player, cb_metadata_get, ctxt); eldbus_proxy_event_callback_add(ctxt->mpris2_player, ELDBUS_PROXY_EVENT_PROPERTY_CHANGED, prop_changed, ctxt); + eldbus_name_owner_has(ctxt->conn, bus, cb_name_owner_has, ctxt); return EINA_TRUE; }