kdeconnect-kde/plugins/mpriscontrol
Weixuan Xiao f1843cb492 Improve D-Bus implementation on macOS
Better patch to replace !218.

- Auto and quick detection of previous D-Bus instance;
- Remove private D-Bus compile definition, only use it on macOS without an existing D-Bus instance;
- Safe reboot after crashes because the indicator is not relating on the kdeconnectd to run a D-Bus session;
- Safe exit after clicking on `Quit` in the systray.


More details in commit logs:

Only enable private D-Bus on macOS because the other platforms do not
need them.
The app should be able to easily detect the session bus from the env
DBUS_LAUNCHD_SESSION_BUS_SOCKET from launchd through launchctl.
Because https://gitlab.freedesktop.org/dbus/dbus/-/blob/master/dbus/dbus-sysdeps-unix.c#L4392
shows that it is the only probing method on macOS with launchd.

The D-Bus session bus can be easily found from launchd/launchctl
with DBUS_LAUNCHD_SESSION_BUS_SOCKET env. It can be an external one
(installed from HomeBrew) or an internal one (launched by a previous
instance followed by a crash).

The indicator helper on macOS can now automatically detect whether we can use a potentially
(with launchd/launchctl env set, or KDE Connect macOS
private_bus_address set) existed and usable session bus.
If previous bus is usable, just try to launch the kdeconnectd with us.
Otherwise, launch a private D-Bus daemon, export the launchd/launchctl
env, and run a kdeconnectd instance.

Everything works better and quicker now :)
2022-04-12 05:40:03 +00:00
..
CMakeLists.txt Clean up unneeded JSON parameter in kcoreaddons_add_plugin 2021-06-28 20:33:52 +02:00
kdeconnect_mpriscontrol.json SVN_SILENT made messages (.desktop file) - always resolve ours 2021-11-04 01:16:42 +00:00
mpriscontrolplugin-win.cpp mpriscontrolplugin-win: add nullptr check for autoRepeatMode and isShuffleActive 2021-06-24 15:29:43 +05:30
mpriscontrolplugin-win.h mpriscontrolplugin: resolve AUMID to display name of the media app when possible 2021-06-15 17:17:52 +05:30
mpriscontrolplugin.cpp Improve D-Bus implementation on macOS 2022-04-12 05:40:03 +00:00
mpriscontrolplugin.h Convert license headers to SPDX expressions 2020-08-17 09:48:10 +00:00
org.freedesktop.DBus.Properties.xml Use generated DBus interface in mpriscontrol 2020-01-20 17:36:44 +01:00
org.mpris.MediaPlayer2.Player.xml Use generated DBus interface in mpriscontrol 2020-01-20 17:36:44 +01:00
org.mpris.MediaPlayer2.xml Use generated DBus interface in mpriscontrol 2020-01-20 17:36:44 +01:00
README Move the plugins into a different top-ĺevel directory 2014-06-14 16:34:11 +02:00

This plugin controls the playback of mpris-enabled applications in this device,
commanded by its counterpart in the other device that acts as a remote control.
That means both plugins are not symmetrical.

This plugins receives and sends packages with type kdeconnect.mpris.

It keeps a list of detected players it can control via MPRIS. When it receives
a package that contains the boolean "requestPlayerList" set to true, it will
send back the list of players in an array named "playerList". If a new player is
detected or a known one dissappears, it should also send this list. Note that
players are identified only by its name (its MPRIS Identity), so there can not
be two players with the same display name.

This plugins also reports the current song, extracted from MPRIS Metadata. It
should send it when it changes or when receiving a package containing a boolean
"requestNowPlaying" set to true.

The remote devices can send packages with commands to one of the players. Those
packages will contain a string "player" with the name of the player they want to
command and a string "action" with the name of an MPRIS call (like "Play",
"Next"...).

This plugin can also control the system volume. The peer device can send a
package with "requestVolume" set to true to ask for the current volume, or send
a package with "setVolume" set to an integer in the range [0,100] to change it.