From 748ef06d8a42230a9bafd19df983724a95b9dbf8 Mon Sep 17 00:00:00 2001 From: Sebastian Potasiak Date: Mon, 14 Sep 2015 20:34:40 +0200 Subject: [PATCH 1/3] Hide MPD information when not running --- i3pystatus/mpd.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/i3pystatus/mpd.py b/i3pystatus/mpd.py index 5e7a547..4847f2d 100644 --- a/i3pystatus/mpd.py +++ b/i3pystatus/mpd.py @@ -38,7 +38,7 @@ class MPD(IntervalModule): ("max_field_len", "Defines max length for in truncate_fields defined fields, if truncated, ellipsis are appended as indicator. It's applied *before* max_len. Value of 0 disables this."), ("max_len", "Defines max length for the hole string, if exceeding fields specefied in truncate_fields are truncated equaly. If truncated, ellipsis are appended as indicator. It's applied *after* max_field_len. Value of 0 disables this."), ("truncate_fields", "fields that will be truncated if exceeding max_field_len or max_len."), - + ("hide_inactive", "Hides information when MPD is not running"), ) host = "localhost" @@ -54,6 +54,7 @@ class MPD(IntervalModule): max_field_len = 25 max_len = 100 truncate_fields = ("title", "album", "artist") + hide_inactive = True on_leftclick = "switch_playpause" on_rightclick = "next_song" on_upscroll = on_rightclick @@ -78,8 +79,15 @@ class MPD(IntervalModule): return None def run(self): - status = self._mpd_command(self.s, "status") - currentsong = self._mpd_command(self.s, "currentsong") + try: + status = self._mpd_command(self.s, "status") + currentsong = self._mpd_command(self.s, "currentsong") + except Exception: + self.output = { + "full_text": "" + } + return + fdict = { "pos": int(status.get("song", 0)) + 1, "len": int(status["playlistlength"]), From df997058f878f4c31eddba53676393e7cef0dc46 Mon Sep 17 00:00:00 2001 From: Sebastian Potasiak Date: Mon, 14 Sep 2015 20:35:37 +0200 Subject: [PATCH 2/3] Revert "Hide MPD information when not running" This reverts commit 748ef06d8a42230a9bafd19df983724a95b9dbf8. --- i3pystatus/mpd.py | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/i3pystatus/mpd.py b/i3pystatus/mpd.py index 4847f2d..5e7a547 100644 --- a/i3pystatus/mpd.py +++ b/i3pystatus/mpd.py @@ -38,7 +38,7 @@ class MPD(IntervalModule): ("max_field_len", "Defines max length for in truncate_fields defined fields, if truncated, ellipsis are appended as indicator. It's applied *before* max_len. Value of 0 disables this."), ("max_len", "Defines max length for the hole string, if exceeding fields specefied in truncate_fields are truncated equaly. If truncated, ellipsis are appended as indicator. It's applied *after* max_field_len. Value of 0 disables this."), ("truncate_fields", "fields that will be truncated if exceeding max_field_len or max_len."), - ("hide_inactive", "Hides information when MPD is not running"), + ) host = "localhost" @@ -54,7 +54,6 @@ class MPD(IntervalModule): max_field_len = 25 max_len = 100 truncate_fields = ("title", "album", "artist") - hide_inactive = True on_leftclick = "switch_playpause" on_rightclick = "next_song" on_upscroll = on_rightclick @@ -79,15 +78,8 @@ class MPD(IntervalModule): return None def run(self): - try: - status = self._mpd_command(self.s, "status") - currentsong = self._mpd_command(self.s, "currentsong") - except Exception: - self.output = { - "full_text": "" - } - return - + status = self._mpd_command(self.s, "status") + currentsong = self._mpd_command(self.s, "currentsong") fdict = { "pos": int(status.get("song", 0)) + 1, "len": int(status["playlistlength"]), From ff0fa4737cd42aa1cfd6cdcb64072959f3e99a95 Mon Sep 17 00:00:00 2001 From: Sebastian Potasiak Date: Mon, 14 Sep 2015 20:38:09 +0200 Subject: [PATCH 3/3] Hide status information when MPD is not running --- i3pystatus/mpd.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/i3pystatus/mpd.py b/i3pystatus/mpd.py index 5e7a547..2ce2b5c 100644 --- a/i3pystatus/mpd.py +++ b/i3pystatus/mpd.py @@ -38,7 +38,7 @@ class MPD(IntervalModule): ("max_field_len", "Defines max length for in truncate_fields defined fields, if truncated, ellipsis are appended as indicator. It's applied *before* max_len. Value of 0 disables this."), ("max_len", "Defines max length for the hole string, if exceeding fields specefied in truncate_fields are truncated equaly. If truncated, ellipsis are appended as indicator. It's applied *after* max_field_len. Value of 0 disables this."), ("truncate_fields", "fields that will be truncated if exceeding max_field_len or max_len."), - + ("hide_inactive", "Hides status information when MPD is not running"), ) host = "localhost" @@ -54,6 +54,7 @@ class MPD(IntervalModule): max_field_len = 25 max_len = 100 truncate_fields = ("title", "album", "artist") + hide_inactive = True on_leftclick = "switch_playpause" on_rightclick = "next_song" on_upscroll = on_rightclick @@ -78,8 +79,16 @@ class MPD(IntervalModule): return None def run(self): - status = self._mpd_command(self.s, "status") - currentsong = self._mpd_command(self.s, "currentsong") + try: + status = self._mpd_command(self.s, "status") + currentsong = self._mpd_command(self.s, "currentsong") + except Exception: + if self.hide_inactive: + self.output = { + "full_text": "" + } + return + fdict = { "pos": int(status.get("song", 0)) + 1, "len": int(status["playlistlength"]),