diff --git a/utils/mpris/README.md b/utils/mpris/README.md new file mode 100644 index 0000000000000000000000000000000000000000..616952ef17b93c1450ff658bc9a617dd5fa28239 --- /dev/null +++ b/utils/mpris/README.md @@ -0,0 +1,20 @@ +# Get DBus informations to implement it for lektord + +Informations from the zbus book: +https://dbus.pages.freedesktop.org/zbus/client.html + +How to get the `vlc.xml` file: + + vlc & + busctl --user --xml-interface introspect \ + org.mpris.MediaPlayer2.vlc /org/mpris/MediaPlayer2 \ + > vlc.xml + killall vlc + +Now edit the vlc.xml file to only get the DBus interfaces related to MPRIS. How +to get the base rust files to edit later: + + cargo install zbus_xmlgen + zbus-xmlgen mpris.xml > mpris.rs + +Now edit the `mpris.rs` file... diff --git a/utils/mpris/mpris.rs b/utils/mpris/mpris.rs new file mode 100644 index 0000000000000000000000000000000000000000..dc98344d9a4080ba9b15489eadab12776b90f46a --- /dev/null +++ b/utils/mpris/mpris.rs @@ -0,0 +1,170 @@ +//! # DBus interface proxies for: `org.mpris.MediaPlayer2`, `org.mpris.MediaPlayer2.Player` +//! +//! This code was generated by `zbus-xmlgen` `3.1.0` from DBus introspection data. +//! Source: `mpris.xml`. +//! +//! You may prefer to adapt it, instead of using it verbatim. +//! +//! More information can be found in the +//! [Writing a client proxy](https://dbus.pages.freedesktop.org/zbus/client.html) +//! section of the zbus documentation. + +use zbus::dbus_proxy; + +enum MediaPlayerLoopStatus { + None, + Track, + Playlist, +} + +enum MediaPlayerPlaybackStatus { + Playing, + Paused, + Stopped, +} + +/// A valid path must be prefiexed by `/baka/lektor/`. After that we have the +/// variant name in lower case, then a `/`, then the ascii only value. For +/// example we can have: +/// - `/baka/lektor/id/42` +enum MediaPlayerObjectPath { + Id(i64), +} + +impl<'a> From<zbus::zvariant::ObjectPath<'a>> for MediaPlayerObjectPath {} + +#[dbus_proxy(interface = "org.mpris.MediaPlayer2", assume_defaults = true)] +trait MediaPlayer2 { + /// Quit method + fn quit(&self) -> zbus::Result<()>; + + /// Raise method + fn raise(&self) -> zbus::Result<()>; + + /// CanQuit property + #[dbus_proxy(property)] + fn can_quit(&self) -> zbus::Result<bool>; + + /// CanRaise property + #[dbus_proxy(property)] + fn can_raise(&self) -> zbus::Result<bool>; + + /// CanSetFullscreen property + #[dbus_proxy(property)] + fn can_set_fullscreen(&self) -> zbus::Result<bool>; + + /// DesktopEntry property + #[dbus_proxy(property)] + fn desktop_entry(&self) -> zbus::Result<String>; + + /// Fullscreen property + #[dbus_proxy(property)] + fn fullscreen(&self) -> zbus::Result<bool>; + fn set_fullscreen(&self, value: bool) -> zbus::Result<()>; + + /// HasTrackList property + #[dbus_proxy(property)] + fn has_track_list(&self) -> zbus::Result<bool>; + + /// Identity property + #[dbus_proxy(property)] + fn identity(&self) -> zbus::Result<String>; + + /// SupportedMimeTypes property + #[dbus_proxy(property)] + fn supported_mime_types(&self) -> zbus::Result<Vec<String>>; + + /// SupportedUriSchemes property + #[dbus_proxy(property)] + fn supported_uri_schemes(&self) -> zbus::Result<Vec<String>>; +} + +#[dbus_proxy(interface = "org.mpris.MediaPlayer2.Player", assume_defaults = true)] +trait Player { + /// Next method + fn next(&self) -> zbus::Result<()>; + + /// OpenUri method + fn open_uri(&self, id_uri: &str) -> zbus::Result<()>; + + /// Pause method + fn pause(&self) -> zbus::Result<()>; + + /// Play method + fn play(&self) -> zbus::Result<()>; + + /// PlayPause method + fn play_pause(&self) -> zbus::Result<()>; + + /// Previous method + fn previous(&self) -> zbus::Result<()>; + + /// Seek method + fn seek(&self, time_µs: i64) -> zbus::Result<()>; + + /// SetPosition method + fn set_position(&self, track_id: &MediaPlayerObjectPath, time_µs: i64) -> zbus::Result<()>; + + /// Stop method + fn stop(&self) -> zbus::Result<()>; + + /// CanControl property + #[dbus_proxy(property)] + fn can_control(&self) -> zbus::Result<bool>; + + /// CanPause property + #[dbus_proxy(property)] + fn can_pause(&self) -> zbus::Result<bool>; + + /// CanPlay property + #[dbus_proxy(property)] + fn can_play(&self) -> zbus::Result<bool>; + + /// CanSeek property + #[dbus_proxy(property)] + fn can_seek(&self) -> zbus::Result<bool>; + + /// LoopStatus property + #[dbus_proxy(property)] + fn loop_status(&self) -> zbus::Result<String>; + fn set_loop_status(&self, value: &str) -> zbus::Result<()>; + + /// MaximumRate property + #[dbus_proxy(property)] + fn maximum_rate(&self) -> zbus::Result<f64>; + fn set_maximum_rate(&self, value: f64) -> zbus::Result<()>; + + /// Metadata property + #[dbus_proxy(property)] + fn metadata( + &self, + ) -> zbus::Result<std::collections::HashMap<String, zbus::zvariant::OwnedValue>>; + + /// MinimumRate property + #[dbus_proxy(property)] + fn minimum_rate(&self) -> zbus::Result<f64>; + fn set_minimum_rate(&self, value: f64) -> zbus::Result<()>; + + /// PlaybackStatus property + #[dbus_proxy(property)] + fn playback_status(&self) -> zbus::Result<String>; + + /// Position property + #[dbus_proxy(property)] + fn position(&self) -> zbus::Result<i32>; + + /// Rate property + #[dbus_proxy(property)] + fn rate(&self) -> zbus::Result<f64>; + fn set_rate(&self, value: f64) -> zbus::Result<()>; + + /// Shuffle property + #[dbus_proxy(property)] + fn shuffle(&self) -> zbus::Result<f64>; + fn set_shuffle(&self, value: f64) -> zbus::Result<()>; + + /// Volume property + #[dbus_proxy(property)] + fn volume(&self) -> zbus::Result<f64>; + fn set_volume(&self, value: f64) -> zbus::Result<()>; +} diff --git a/utils/mpris/mpris.xml b/utils/mpris/mpris.xml new file mode 100644 index 0000000000000000000000000000000000000000..61f525aeff676d00e7d7115433d0c22a7a39a96c --- /dev/null +++ b/utils/mpris/mpris.xml @@ -0,0 +1,47 @@ +<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> +<node> + <interface name="org.mpris.MediaPlayer2"> + <property name="Identity" type="s" access="read" /> + <property name="DesktopEntry" type="s" access="read" /> + <property name="SupportedMimeTypes" type="as" access="read" /> + <property name="SupportedUriSchemes" type="as" access="read" /> + <property name="HasTrackList" type="b" access="read" /> + <property name="CanQuit" type="b" access="read" /> + <property name="CanSetFullscreen" type="b" access="read" /> + <property name="Fullscreen" type="b" access="readwrite" /> + <property name="CanRaise" type="b" access="read" /> + <method name="Quit" /> + <method name="Raise" /> + </interface> + <interface name="org.mpris.MediaPlayer2.Player"> + <property name="Metadata" type="a{sv}" access="read" /> + <property name="PlaybackStatus" type="s" access="read" /> + <property name="LoopStatus" type="s" access="readwrite" /> + <property name="Volume" type="d" access="readwrite" /> + <property name="Shuffle" type="d" access="readwrite" /> + <property name="Position" type="i" access="read" /> + <property name="Rate" type="d" access="readwrite" /> + <property name="MinimumRate" type="d" access="readwrite" /> + <property name="MaximumRate" type="d" access="readwrite" /> + <property name="CanControl" type="b" access="read" /> + <property name="CanPlay" type="b" access="read" /> + <property name="CanPause" type="b" access="read" /> + <property name="CanSeek" type="b" access="read" /> + <method name="Previous" /> + <method name="Next" /> + <method name="Stop" /> + <method name="Play" /> + <method name="Pause" /> + <method name="PlayPause" /> + <method name="Seek"> + <arg type="x" direction="in" /> + </method> + <method name="OpenUri"> + <arg type="s" direction="in" /> + </method> + <method name="SetPosition"> + <arg type="o" direction="in" /> + <arg type="x" direction="in" /> + </method> + </interface> +</node> \ No newline at end of file diff --git a/utils/mpris/vlc.xml b/utils/mpris/vlc.xml new file mode 100644 index 0000000000000000000000000000000000000000..9d1d97c81478a743fd8bd11ec6e6114e4516457a --- /dev/null +++ b/utils/mpris/vlc.xml @@ -0,0 +1,108 @@ +<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" +"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> +<node> + <interface name="org.freedesktop.DBus.Introspectable"> + <method name="Introspect"> + <arg name="data" direction="out" type="s"/> + </method> + </interface> + <interface name="org.freedesktop.DBus.Properties"> + <method name="Get"> + <arg direction="in" type="s"/> + <arg direction="in" type="s"/> + <arg direction="out" type="v"/> + </method> + <method name="Set"> + <arg direction="in" type="s"/> + <arg direction="in" type="s"/> + <arg direction="in" type="v"/> + </method> + <method name="GetAll"> + <arg direction="in" type="s"/> + <arg direction="out" type="a{sv}"/> + </method> + <signal name="PropertiesChanged"> + <arg type="s"/> + <arg type="a{sv}"/> + <arg type="as"/> + </signal> + </interface> + <interface name="org.mpris.MediaPlayer2"> + <property name="Identity" type="s" access="read" /> + <property name="DesktopEntry" type="s" access="read" /> + <property name="SupportedMimeTypes" type="as" access="read" /> + <property name="SupportedUriSchemes" type="as" access="read" /> + <property name="HasTrackList" type="b" access="read" /> + <property name="CanQuit" type="b" access="read" /> + <property name="CanSetFullscreen" type="b" access="read" /> + <property name="Fullscreen" type="b" access="readwrite" /> + <property name="CanRaise" type="b" access="read" /> + <method name="Quit" /> + <method name="Raise" /> + </interface> + <interface name="org.mpris.MediaPlayer2.Player"> + <property name="Metadata" type="a{sv}" access="read" /> + <property name="PlaybackStatus" type="s" access="read" /> + <property name="LoopStatus" type="s" access="readwrite" /> + <property name="Volume" type="d" access="readwrite" /> + <property name="Shuffle" type="d" access="readwrite" /> + <property name="Position" type="i" access="read" /> + <property name="Rate" type="d" access="readwrite" /> + <property name="MinimumRate" type="d" access="readwrite" /> + <property name="MaximumRate" type="d" access="readwrite" /> + <property name="CanControl" type="b" access="read" /> + <property name="CanPlay" type="b" access="read" /> + <property name="CanPause" type="b" access="read" /> + <property name="CanSeek" type="b" access="read" /> + <method name="Previous" /> + <method name="Next" /> + <method name="Stop" /> + <method name="Play" /> + <method name="Pause" /> + <method name="PlayPause" /> + <method name="Seek"> + <arg type="x" direction="in" /> + </method> <method name="OpenUri"> + <arg type="s" direction="in" /> + </method> + <method name="SetPosition"> + <arg type="o" direction="in" /> + <arg type="x" direction="in" /> + </method> + </interface> + <interface name="org.mpris.MediaPlayer2.TrackList"> + <property name="Tracks" type="ao" access="read" /> + <property name="CanEditTracks" type="b" access="read" /> + <method name="GetTracksMetadata"> + <arg type="ao" direction="in" /> + <arg type="aa{sv}" direction="out" /> + </method> + <method name="AddTrack"> + <arg type="s" direction="in" /> + <arg type="o" direction="in" /> + <arg type="b" direction="in" /> + </method> + <method name="RemoveTrack"> + <arg type="o" direction="in" /> + </method> + <method name="GoTo"> + <arg type="o" direction="in" /> + </method> + <signal name="TrackListReplaced"> + <arg type="ao" /> + <arg type="o" /> + </signal> + <signal name="TrackAdded"> + <arg type="a{sv}" /> + <arg type="o" /> + </signal> + <signal name="TrackRemoved"> + <arg type="o" /> + </signal> + <signal name="TrackMetadataChanged"> + <arg type="o" /> + <arg type="a{sv}" /> + </signal> + </interface> +</node> +