From 713c93c3ffb49e57a4f89313ba715ace0f00c85b Mon Sep 17 00:00:00 2001 From: ncoop Date: Wed, 28 Dec 2016 01:15:13 -0800 Subject: [PATCH 1/3] Implement and document mpd_command method. --- i3pystatus/mpd.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/i3pystatus/mpd.py b/i3pystatus/mpd.py index a3d0781..4ab09ea 100644 --- a/i3pystatus/mpd.py +++ b/i3pystatus/mpd.py @@ -36,6 +36,21 @@ Emulates ``mpc toggle``. next``. * ``previous_song`` — Goes to previous track in the playlist. Emulates \ ``mpc prev``. + * ``mpd_command`` — Send a command directly to MPD's socket. The command \ +is the second element of the list. Documentation for available commands can \ +be found at https://www.musicpd.org/doc/protocol/command_reference.html + + Example module registration with callbacks: + + :: + + status.register("mpd", + on_leftclick="switch_playpause", + on_rightclick=["mpd_command", "stop"], + on_middleclick=["mpd_command", "shuffle"], + on_upscroll=["mpd_command", "seekcur -10"], + on_downscroll=["mpd_command", "seekcur +10"]) + """ interval = 1 @@ -187,3 +202,9 @@ cleartext to the server.)"), self._mpd_command(self.s, "previous") except Exception as e: pass + + def mpd_command(self, command): + try: + self._mpd_command(self.s, command) + except Exception as e: + pass From 40cff0d6b16c3a9d59883c8289f3ecfdd885d16e Mon Sep 17 00:00:00 2001 From: ncoop Date: Wed, 28 Dec 2016 01:16:35 -0800 Subject: [PATCH 2/3] "The use of pause command w/o the PAUSE argument is deprecated." --- i3pystatus/mpd.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i3pystatus/mpd.py b/i3pystatus/mpd.py index 4ab09ea..e4e03cc 100644 --- a/i3pystatus/mpd.py +++ b/i3pystatus/mpd.py @@ -181,7 +181,7 @@ cleartext to the server.)"), try: self._mpd_command(self.s, "play" if self._mpd_command(self.s, "status")["state"] - in ["pause", "stop"] else "pause") + in ["pause", "stop"] else "pause 1") except Exception as e: pass From ea26373a78c3b33a5f899e2190b5d32ae078d84c Mon Sep 17 00:00:00 2001 From: ncoop Date: Wed, 28 Dec 2016 01:36:48 -0800 Subject: [PATCH 3/3] Documented a possible bug with mpd. --- i3pystatus/mpd.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/i3pystatus/mpd.py b/i3pystatus/mpd.py index e4e03cc..ab4809c 100644 --- a/i3pystatus/mpd.py +++ b/i3pystatus/mpd.py @@ -51,6 +51,9 @@ be found at https://www.musicpd.org/doc/protocol/command_reference.html on_upscroll=["mpd_command", "seekcur -10"], on_downscroll=["mpd_command", "seekcur +10"]) + Note that ``next_song`` and ``previous_song``, and their ``mpd_command`` \ +equivalents, are ignored while mpd is stopped. + """ interval = 1