From ae8a57afdc8d71dfa86f62c716bf65d9252ae8df Mon Sep 17 00:00:00 2001 From: Aaron Fordham Date: Thu, 10 Sep 2015 12:05:29 +0000 Subject: [PATCH 01/14] Adding moon phase module --- i3pystatus/moon.py | 133 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 i3pystatus/moon.py diff --git a/i3pystatus/moon.py b/i3pystatus/moon.py new file mode 100644 index 0000000..ef11007 --- /dev/null +++ b/i3pystatus/moon.py @@ -0,0 +1,133 @@ +from i3pystatus import IntervalModule, formatp + +import datetime +import math +import decimal +#import ephem +import os +from i3pystatus.core.util import TimeWrapper + + +dec = decimal.Decimal + +# Moon phase module +class MoonPhase(IntervalModule): + + """ + Available Formatters + + status: Allow for mapping of current moon phase + status { + + New Moon: + Waxing Crescent: + First Quarter: + Waxing Gibbous: + Full Moon: + Waning Gibbous: + Last Quarter: + Waning Crescent: + } + + + """ + + settings = ( + "format", + ("status", "Current moon phase"), + ("illum", "Percentage that is illuminated"), + ("color", "Set color"), + + ) + + format = "{illum} {status}" + + interval = 60 * 60 * 2 # every 2 hours + + + status = { + + "New Moon": "NM", + "Waxing Crescent": "WaxCres", + "First Quarter": "FQ", + "Waxing Gibbous": "WaxGib", + "Full Moon": "FM", + "Waning Gibbous": "WanGib", + "Last Quarter": "LQ", + "Waning Cresent": "WanCres", + + } + + phase_color = { + "New Moon": "#00BDE5", + "Waxing Crescent": "#138DD8", + "First Quarter": "#265ECC", + "Waxing Gibbous": "#392FBF", + "Full Moon": "#4C00B3", + "Waning Gibbous": "#871181", + "Last Quarter": "#C32250", + "Waning Crescent": "#FF341F", + } + + + def pos(now=None): + now = None + days_in_second = 86400 + + if now is None: + now = datetime.datetime.now() + + difference = now - datetime.datetime(2001,1,1) + + days = dec(difference.days) + (dec(difference.seconds)/dec(days_in_second)) + + lunarCycle = dec("0.20439731") + (days * dec("0.03386319269")) + + return lunarCycle % dec(1) + + + def current_phase(self): + + lunarCycle = self.pos() + + index = (lunarCycle * dec(8)) + dec("0.5") + index = math.floor(index) + + return { + 0: "New Moon", + 1: "Waxing Crescent", + 2: "First Quarter", + 3: "Waxing Gibbous", + 4: "Full Moon", + 5: "Waning Gibbous", + 6: "Last Quarter", + 7: "Waning Crescent", + }[int(index) & 7] + + def illum(self): + phase = 0 + lunarCycle = float(self.pos())*100 + + if lunarCycle > 50: + + phase = 100 - lunarCycle + + else: + phase = lunarCycle*2 + + return phase + + def run(self): + + + fdict= { + "status" : self.status[self.current_phase()], + "illum" : self.illum(), + #"phase_color": self.phase_color[self.current_phase()], + } + self.output = { + "full_text": formatp(self.format,**fdict), + "color": self.phase_color[self.current_phase()], + } + + From e939d54eaff1eb90a7f76ac147dfa382a3268638 Mon Sep 17 00:00:00 2001 From: Aaron Fordham Date: Thu, 10 Sep 2015 23:41:04 +0000 Subject: [PATCH 02/14] Adding moon phase module --- i3pystatus/moon.py | 186 +++++++++++++++++++++------------------------ 1 file changed, 88 insertions(+), 98 deletions(-) diff --git a/i3pystatus/moon.py b/i3pystatus/moon.py index ef11007..d13177a 100644 --- a/i3pystatus/moon.py +++ b/i3pystatus/moon.py @@ -3,131 +3,121 @@ from i3pystatus import IntervalModule, formatp import datetime import math import decimal -#import ephem import os from i3pystatus.core.util import TimeWrapper - dec = decimal.Decimal + # Moon phase module class MoonPhase(IntervalModule): - """ - Available Formatters - - status: Allow for mapping of current moon phase - status { - - New Moon: - Waxing Crescent: - First Quarter: - Waxing Gibbous: - Full Moon: - Waning Gibbous: - Last Quarter: - Waning Crescent: - } + """ + Available Formatters + status: Allow for mapping of current moon phase + status { - """ - - settings = ( - "format", - ("status", "Current moon phase"), - ("illum", "Percentage that is illuminated"), - ("color", "Set color"), + New Moon: + Waxing Crescent: + First Quarter: + Waxing Gibbous: + Full Moon: + Waning Gibbous: + Last Quarter: + Waning Crescent: + } + """ - ) + settings = ( + "format", + ("status", "Current moon phase"), + ("illum", "Percentage that is illuminated"), + ("color", "Set color"), - format = "{illum} {status}" + ) - interval = 60 * 60 * 2 # every 2 hours + format = "{illum} {status}" + interval = 60 * 60 * 2 # every 2 hours - status = { + status = { - "New Moon": "NM", - "Waxing Crescent": "WaxCres", - "First Quarter": "FQ", - "Waxing Gibbous": "WaxGib", - "Full Moon": "FM", - "Waning Gibbous": "WanGib", - "Last Quarter": "LQ", - "Waning Cresent": "WanCres", - - } + "New Moon": "NM", + "Waxing Crescent": "WaxCres", + "First Quarter": "FQ", + "Waxing Gibbous": "WaxGib", + "Full Moon": "FM", + "Waning Gibbous": "WanGib", + "Last Quarter": "LQ", + "Waning Cresent": "WanCres", - phase_color = { - "New Moon": "#00BDE5", - "Waxing Crescent": "#138DD8", - "First Quarter": "#265ECC", - "Waxing Gibbous": "#392FBF", - "Full Moon": "#4C00B3", - "Waning Gibbous": "#871181", - "Last Quarter": "#C32250", - "Waning Crescent": "#FF341F", - } + } + phase_color = { + "New Moon": "#00BDE5", + "Waxing Crescent": "#138DD8", + "First Quarter": "#265ECC", + "Waxing Gibbous": "#392FBF", + "Full Moon": "#4C00B3", + "Waning Gibbous": "#871181", + "Last Quarter": "#C32250", + "Waning Crescent": "#FF341F", + } - def pos(now=None): - now = None - days_in_second = 86400 + def pos(now=None): + now = None + days_in_second = 86400 - if now is None: - now = datetime.datetime.now() + if now is None: + now = datetime.datetime.now() - difference = now - datetime.datetime(2001,1,1) - - days = dec(difference.days) + (dec(difference.seconds)/dec(days_in_second)) + difference = now - datetime.datetime(2001, 1, 1) - lunarCycle = dec("0.20439731") + (days * dec("0.03386319269")) - - return lunarCycle % dec(1) + days = dec(difference.days) + (dec(difference.seconds) / dec(days_in_second)) + lunarCycle = dec("0.20439731") + (days * dec("0.03386319269")) - def current_phase(self): + return lunarCycle % dec(1) - lunarCycle = self.pos() - - index = (lunarCycle * dec(8)) + dec("0.5") - index = math.floor(index) + def current_phase(self): - return { - 0: "New Moon", - 1: "Waxing Crescent", - 2: "First Quarter", - 3: "Waxing Gibbous", - 4: "Full Moon", - 5: "Waning Gibbous", - 6: "Last Quarter", - 7: "Waning Crescent", - }[int(index) & 7] - - def illum(self): - phase = 0 - lunarCycle = float(self.pos())*100 - - if lunarCycle > 50: + lunarCycle = self.pos() - phase = 100 - lunarCycle + index = (lunarCycle * dec(8)) + dec("0.5") + index = math.floor(index) - else: - phase = lunarCycle*2 - - return phase - - def run(self): - - - fdict= { - "status" : self.status[self.current_phase()], - "illum" : self.illum(), - #"phase_color": self.phase_color[self.current_phase()], - } - self.output = { - "full_text": formatp(self.format,**fdict), - "color": self.phase_color[self.current_phase()], - } + return { + 0: "New Moon", + 1: "Waxing Crescent", + 2: "First Quarter", + 3: "Waxing Gibbous", + 4: "Full Moon", + 5: "Waning Gibbous", + 6: "Last Quarter", + 7: "Waning Crescent", + }[int(index) & 7] + def illum(self): + phase = 0 + lunarCycle = float(self.pos()) * 100 + if lunarCycle > 50: + phase = 100 - lunarCycle + + else: + phase = lunarCycle * 2 + + return phase + + def run(self): + + fdict = { + "status": self.status[self.current_phase()], + "illum": self.illum(), + } + + self.output = { + "full_text": formatp(self.format, **fdict), + "color": self.phase_color[self.current_phase()], + } From 12a9aeebb9066a9b8a714b87badc8042f24136fe Mon Sep 17 00:00:00 2001 From: gutodisse1 Date: Thu, 10 Sep 2015 23:18:11 -0300 Subject: [PATCH 03/14] Update cpu_usage.py Add color option on cpu_usage.py --- i3pystatus/cpu_usage.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/i3pystatus/cpu_usage.py b/i3pystatus/cpu_usage.py index 5df3dc7..ad1ff2f 100644 --- a/i3pystatus/cpu_usage.py +++ b/i3pystatus/cpu_usage.py @@ -28,12 +28,14 @@ class CpuUsage(IntervalModule): format_all = "{core}:{usage:02}%" exclude_average = False interval = 1 + color = None settings = ( ("format", "format string."), ("format_all", ("format string used for {usage_all} per core. " "Available formaters are {core} and {usage}. ")), ("exclude_average", ("If True usage average of all cores will " - "not be in format_all.")) + "not be in format_all.")), + ("color", "HTML color code #RRGGBB") ) def init(self): @@ -117,5 +119,6 @@ class CpuUsage(IntervalModule): usage['usage'] = usage['usage_cpu'] self.output = { - "full_text": self.format.format_map(usage) + "full_text": self.format.format_map(usage), + "color": self.color } From 78ec23a506d3211f4a4029d9db6591ec9c4e0edc Mon Sep 17 00:00:00 2001 From: gutodisse1 Date: Fri, 11 Sep 2015 00:05:45 -0300 Subject: [PATCH 04/14] Update README.rst Review CONTRIBUTORS link --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 94e2350..cee6975 100644 --- a/README.rst +++ b/README.rst @@ -47,7 +47,7 @@ Changelog Contributors ------------ -A list of all contributors can be found in `CONTRIBUTORS `_. +A list of all contributors can be found in `CONTRIBUTORS `_. Particular noteworthy contributors are former maintainer Jan Oliver Oelerich and current maintainer enkore. From 78d9bdda27391852bfd2ef00b059b9e5a5a02f9b Mon Sep 17 00:00:00 2001 From: Aaron Fordham Date: Fri, 11 Sep 2015 09:13:10 +0000 Subject: [PATCH 05/14] Adding moon phase module --- i3pystatus/moon.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/i3pystatus/moon.py b/i3pystatus/moon.py index d13177a..e049fa9 100644 --- a/i3pystatus/moon.py +++ b/i3pystatus/moon.py @@ -54,6 +54,8 @@ class MoonPhase(IntervalModule): } + color = "#ffffff" + phase_color = { "New Moon": "#00BDE5", "Waxing Crescent": "#138DD8", @@ -112,6 +114,8 @@ class MoonPhase(IntervalModule): def run(self): + color = self.color + fdict = { "status": self.status[self.current_phase()], "illum": self.illum(), From f8223286e058e2ef27b4cde733f2faa51521e5c7 Mon Sep 17 00:00:00 2001 From: Aaron Fordham Date: Fri, 11 Sep 2015 10:32:43 +0000 Subject: [PATCH 06/14] Adding moon phase module --- i3pystatus/moon.py | 193 +++++++++++++++++++++------------------------ 1 file changed, 92 insertions(+), 101 deletions(-) diff --git a/i3pystatus/moon.py b/i3pystatus/moon.py index e049fa9..8e19819 100644 --- a/i3pystatus/moon.py +++ b/i3pystatus/moon.py @@ -2,8 +2,10 @@ from i3pystatus import IntervalModule, formatp import datetime import math + import decimal import os + from i3pystatus.core.util import TimeWrapper dec = decimal.Decimal @@ -11,117 +13,106 @@ dec = decimal.Decimal # Moon phase module class MoonPhase(IntervalModule): + """ + Available Formatters - """ - Available Formatters + status: Allows for mapping of current moon phase to various + - New Moon: + - Waxing Crescent: + - First Quarter: + - Waxing Gibbous: + - Full Moon: + - Waning Gibbous: + - Last Quarter: + - Waning Crescent: - status: Allow for mapping of current moon phase - status { + """ - New Moon: - Waxing Crescent: - First Quarter: - Waxing Gibbous: - Full Moon: - Waning Gibbous: - Last Quarter: - Waning Crescent: - } - """ + settings = ( + "format", + ("status", "Current moon phase"), + ("illum", "Percentage that is illuminated"), + ("color", "Set color"), - settings = ( - "format", - ("status", "Current moon phase"), - ("illum", "Percentage that is illuminated"), - ("color", "Set color"), + ) - ) + format = "{illum} {status}" - format = "{illum} {status}" + interval = 60 * 60 * 2 # every 2 hours - interval = 60 * 60 * 2 # every 2 hours + status = { - status = { + "New Moon": "NM", + "Waxing Crescent": "WaxCres", + "First Quarter": "FQ", + "Waxing Gibbous": "WaxGib", + "Full Moon": "FM", + "Waning Gibbous": "WanGib", + "Last Quarter": "LQ", + "Waning Cresent": "WanCres", - "New Moon": "NM", - "Waxing Crescent": "WaxCres", - "First Quarter": "FQ", - "Waxing Gibbous": "WaxGib", - "Full Moon": "FM", - "Waning Gibbous": "WanGib", - "Last Quarter": "LQ", - "Waning Cresent": "WanCres", + } + color = { + "New Moon": "#00BDE5", + "Waxing Crescent": "#138DD8", + "First Quarter": "#265ECC", + "Waxing Gibbous": "#392FBF", + "Full Moon": "#4C00B3", + "Waning Gibbous": "#871181", + "Last Quarter": "#C32250", + "Waning Crescent": "#FF341F", + } + + def pos(now=None): + days_in_second = 86400 + + now = datetime.datetime.now() + difference = now - datetime.datetime(2001, 1, 1) + + days = dec(difference.days) + (dec(difference.seconds) / dec(days_in_second)) + lunarCycle = dec("0.20439731") + (days * dec("0.03386319269")) + + return lunarCycle % dec(1) + + def current_phase(self): + + lunarCycle = self.pos() + + index = (lunarCycle * dec(8)) + dec("0.5") + index = math.floor(index) + + return { + 0: "New Moon", + 1: "Waxing Crescent", + 2: "First Quarter", + 3: "Waxing Gibbous", + 4: "Full Moon", + 5: "Waning Gibbous", + 6: "Last Quarter", + 7: "Waning Crescent", + }[int(index) & 7] + + def illum(self): + phase = 0 + lunarCycle = float(self.pos()) * 100 + + if lunarCycle > 50: + phase = 100 - lunarCycle + + else: + phase = lunarCycle * 2 + + return phase + + def run(self): + + fdict = { + "status": self.status[self.current_phase()], + "illum": self.illum(), } - color = "#ffffff" - - phase_color = { - "New Moon": "#00BDE5", - "Waxing Crescent": "#138DD8", - "First Quarter": "#265ECC", - "Waxing Gibbous": "#392FBF", - "Full Moon": "#4C00B3", - "Waning Gibbous": "#871181", - "Last Quarter": "#C32250", - "Waning Crescent": "#FF341F", + self.output = { + "full_text": formatp(self.format, **fdict), + "color": self.color[self.current_phase()], } - - def pos(now=None): - now = None - days_in_second = 86400 - - if now is None: - now = datetime.datetime.now() - - difference = now - datetime.datetime(2001, 1, 1) - - days = dec(difference.days) + (dec(difference.seconds) / dec(days_in_second)) - - lunarCycle = dec("0.20439731") + (days * dec("0.03386319269")) - - return lunarCycle % dec(1) - - def current_phase(self): - - lunarCycle = self.pos() - - index = (lunarCycle * dec(8)) + dec("0.5") - index = math.floor(index) - - return { - 0: "New Moon", - 1: "Waxing Crescent", - 2: "First Quarter", - 3: "Waxing Gibbous", - 4: "Full Moon", - 5: "Waning Gibbous", - 6: "Last Quarter", - 7: "Waning Crescent", - }[int(index) & 7] - - def illum(self): - phase = 0 - lunarCycle = float(self.pos()) * 100 - - if lunarCycle > 50: - phase = 100 - lunarCycle - - else: - phase = lunarCycle * 2 - - return phase - - def run(self): - - color = self.color - - fdict = { - "status": self.status[self.current_phase()], - "illum": self.illum(), - } - - self.output = { - "full_text": formatp(self.format, **fdict), - "color": self.phase_color[self.current_phase()], - } From a7460dc9e95c92cfc14c15138884816c259c0a33 Mon Sep 17 00:00:00 2001 From: Aaron Fordham Date: Fri, 11 Sep 2015 10:38:14 +0000 Subject: [PATCH 07/14] Adding moon phase module --- i3pystatus/moon.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i3pystatus/moon.py b/i3pystatus/moon.py index 8e19819..a01fdeb 100644 --- a/i3pystatus/moon.py +++ b/i3pystatus/moon.py @@ -16,7 +16,7 @@ class MoonPhase(IntervalModule): """ Available Formatters - status: Allows for mapping of current moon phase to various + status: Allows for mapping of current moon phase - New Moon: - Waxing Crescent: - First Quarter: From ddb97dfbdf374f834584587c9aad990fc93b0479 Mon Sep 17 00:00:00 2001 From: Holden Salomon Date: Sun, 13 Sep 2015 16:59:22 -0400 Subject: [PATCH 08/14] Total rewrite into an IntervalModule, how it should have been. Added {status}, format_not_running, color_not_running, and comments to make it readable. This improvement was loosely based on the cmus module --- CONTRIBUTORS | 1 + i3pystatus/spotify.py | 123 +++++++++++++++++++++++++----------------- 2 files changed, 76 insertions(+), 48 deletions(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 63292c6..66e1301 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -24,6 +24,7 @@ gacekjk Georg Sieber Goran Mekić Gordon Schulz +Holden Salomon Hugo Osvaldo Barrera Iliyas Jorio Ismael diff --git a/i3pystatus/spotify.py b/i3pystatus/spotify.py index a4a97bb..de57765 100644 --- a/i3pystatus/spotify.py +++ b/i3pystatus/spotify.py @@ -1,78 +1,105 @@ -import threading import math - -from i3pystatus import Module -from gi.repository import Playerctl, GLib +from i3pystatus import formatp +from i3pystatus import IntervalModule +from gi.repository import Playerctl -class Spotify(Module): +class Spotify(IntervalModule): """ - This class shows information from Spotify. + Gets Spotify info using playerctl - Left click will toggle pause/play of the current song. - Right click will skip the song. + .. rubric:: Available formatters - Dependent on Playerctl ( https://github.com/acrisci/playerctl ) and GLib + * `{status}` — current status icon (paused/playing) + * `{length}` — total song duration (mm:ss format) + * `{artist}` — artist + * `{title}` — title + * `{album}` — album """ - format = "{artist} - {title}" - color = "#ffffff" - settings = ( - ("format", "Format string. {artist}, {title}, {album}, {volume}, and {length} are available for output."), - ("color", "color of the output"), + ('format', 'formatp string'), + ('format_not_running', 'Text to show if cmus is not running'), + ('color', 'The color of the text'), + ('color_not_running', 'The color of the text, when cmus is not running'), + ('status', 'Dictionary mapping status to output'), ) - on_leftclick = "switch_playpause" - on_rightclick = "next_song" + # default settings + color = '#ffffff' + color_not_running = '#ffffff' + format = '{status} {length} {artist} - {title}' + format_not_running = 'Not running' + interval = 1 + status = { + 'paused': '▷', + 'playing': '▶', + } - def main_loop(self): - """ Mainloop blocks so we thread it.""" - self.player = Playerctl.Player() - self.player.on('metadata', self.set_status) + on_leftclick = 'playpause' + on_rightclick = 'next_song' + on_upscroll = 'next_song' - if self.player.props.status != "": - self.set_status(self.player) + def get_info(self, player): + """gets spotify track info from playerctl""" - main = GLib.MainLoop() - main.run() - - def init(self): - try: - t = threading.Thread(target=self.main_loop) - t.daemon = True - t.start() - except Exception as e: - self.output = { - "full_text": "Error creating new thread!", - "color": "#FF0000" - } - - def set_status(self, player, e=None): artist = player.get_artist() title = player.get_title() album = player.get_album() - volume = player.props.volume + status = player.props.status + # gets the length of spotify through the metadata command length = "" - if e is not None: - time = e["mpris:length"] / 60.0e6 + + # stores the metadata and checks if it is valid + metadata = player.props.metadata + if metadata is not None: + # math to convert the number stored in mpris:length to a human readable format + time = dict(metadata)["mpris:length"] / 60.0e6 minutes = math.floor(time) seconds = round(time % 1 * 60) if seconds < 10: seconds = "0" + str(seconds) length = "{}:{}".format(minutes, seconds) - self.output = { - "full_text": self.format.format( - artist=artist, title=title, - album=album, length=length, - volume=volume), - "color": self.color - } + # sets length to an empty string if it does not exist for whatever reason. This should usually not happen + else: + length = "" - def switch_playpause(self): + # returns a dictionary of all spotify data + return {"artist": artist, "title": title, "album": album, "status": status, "length": length} + + def run(self): + """Main statement, executes all code every interval""" + + # tries to create player object and get data from player + try: + self.player = Playerctl.Player() + + self.output = {} + response = self.get_info(self.player) + + # creates a dictionary of the spotify data captured + fdict = { + 'status': self.status[response['status'].lower()], + 'title': response["title"], + 'album': response.get('album', ''), + 'artist': response.get('artist', ''), + 'length': response.get('length', 0), + } + # outputs the dictionary in the default (or specified) color + self.output['full_text'] = formatp(self.format, **fdict) + self.output['color'] = self.color + + # outputs the not running string if spotify is closed + except: + self.output['full_text'] = self.format_not_running + self.output['color'] = self.color_not_running + + def playpause(self): + """Pauses and plays spotify""" self.player.play_pause() def next_song(self): + """skips to the next song""" self.player.next() From 748ef06d8a42230a9bafd19df983724a95b9dbf8 Mon Sep 17 00:00:00 2001 From: Sebastian Potasiak Date: Mon, 14 Sep 2015 20:34:40 +0200 Subject: [PATCH 09/14] 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 10/14] 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 11/14] 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"]), From ca846902651963e5aad57f30e746b925aa504dfe Mon Sep 17 00:00:00 2001 From: Holden Salomon Date: Wed, 16 Sep 2015 20:34:00 -0400 Subject: [PATCH 12/14] Fixed random flashing of the module output --- i3pystatus/spotify.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/i3pystatus/spotify.py b/i3pystatus/spotify.py index de57765..4404fe8 100644 --- a/i3pystatus/spotify.py +++ b/i3pystatus/spotify.py @@ -76,7 +76,6 @@ class Spotify(IntervalModule): try: self.player = Playerctl.Player() - self.output = {} response = self.get_info(self.player) # creates a dictionary of the spotify data captured @@ -87,14 +86,13 @@ class Spotify(IntervalModule): 'artist': response.get('artist', ''), 'length': response.get('length', 0), } - # outputs the dictionary in the default (or specified) color - self.output['full_text'] = formatp(self.format, **fdict) - self.output['color'] = self.color + self.output = {"full_text": formatp(self.format, **fdict), + "color": self.color} # outputs the not running string if spotify is closed except: - self.output['full_text'] = self.format_not_running - self.output['color'] = self.color_not_running + self.output = {"full_text": self.format_not_running, + "color": self.color_not_running} def playpause(self): """Pauses and plays spotify""" From c70808ca1f7374a593137a867e9338ff22a6d410 Mon Sep 17 00:00:00 2001 From: enkore Date: Wed, 23 Sep 2015 12:51:11 +0200 Subject: [PATCH 13/14] mpd: don't change default error handling --- i3pystatus/mpd.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i3pystatus/mpd.py b/i3pystatus/mpd.py index 2ce2b5c..ad0c006 100644 --- a/i3pystatus/mpd.py +++ b/i3pystatus/mpd.py @@ -54,7 +54,7 @@ class MPD(IntervalModule): max_field_len = 25 max_len = 100 truncate_fields = ("title", "album", "artist") - hide_inactive = True + hide_inactive = False on_leftclick = "switch_playpause" on_rightclick = "next_song" on_upscroll = on_rightclick From 333a6dcdffd7cfb533f0d9d3647c4aa2fe7958bf Mon Sep 17 00:00:00 2001 From: enkore Date: Wed, 23 Sep 2015 12:53:59 +0200 Subject: [PATCH 14/14] Update moon.py --- i3pystatus/moon.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/i3pystatus/moon.py b/i3pystatus/moon.py index a01fdeb..ad22f21 100644 --- a/i3pystatus/moon.py +++ b/i3pystatus/moon.py @@ -11,7 +11,6 @@ from i3pystatus.core.util import TimeWrapper dec = decimal.Decimal -# Moon phase module class MoonPhase(IntervalModule): """ Available Formatters @@ -33,7 +32,6 @@ class MoonPhase(IntervalModule): ("status", "Current moon phase"), ("illum", "Percentage that is illuminated"), ("color", "Set color"), - ) format = "{illum} {status}" @@ -41,7 +39,6 @@ class MoonPhase(IntervalModule): interval = 60 * 60 * 2 # every 2 hours status = { - "New Moon": "NM", "Waxing Crescent": "WaxCres", "First Quarter": "FQ", @@ -50,7 +47,6 @@ class MoonPhase(IntervalModule): "Waning Gibbous": "WanGib", "Last Quarter": "LQ", "Waning Cresent": "WanCres", - } color = { @@ -99,19 +95,16 @@ class MoonPhase(IntervalModule): if lunarCycle > 50: phase = 100 - lunarCycle - else: phase = lunarCycle * 2 return phase def run(self): - fdict = { "status": self.status[self.current_phase()], "illum": self.illum(), } - self.output = { "full_text": formatp(self.format, **fdict), "color": self.color[self.current_phase()],