From 13d6b1e4506aed970725a18ddbc3bbdad6f07533 Mon Sep 17 00:00:00 2001 From: Ultrabug Date: Sun, 21 Dec 2014 20:07:33 +0100 Subject: normalize module name, add standalone test code --- py3status/modules/scratchpad-counter.py | 52 --------------------------------- py3status/modules/scratchpad_counter.py | 52 +++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 52 deletions(-) delete mode 100644 py3status/modules/scratchpad-counter.py create mode 100644 py3status/modules/scratchpad_counter.py (limited to 'py3status') diff --git a/py3status/modules/scratchpad-counter.py b/py3status/modules/scratchpad-counter.py deleted file mode 100644 index 0b2eec7..0000000 --- a/py3status/modules/scratchpad-counter.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Module showing amount of windows at the scratchpad. - -@author shadowprince -@license Eclipse Public License -""" - -import i3 -from time import time - - -def find_scratch(tree): - if tree["name"] == "__i3_scratch": - return tree - else: - for x in tree["nodes"]: - result = find_scratch(x) - if result: - return result - return None - - -class Py3status: - - # available configuration parameters - cache_timeout = 5 - format = "{} ⌫" # format of indicator. {} replaces with count of windows - hide_when_none = False # hide indicator when there is no windows - - def __init__(self): - self.count = -1 - - def scratchpad_counter(self, i3s_output_list, i3s_config): - count = len(find_scratch(i3.get_tree()).get("floating_nodes", [])) - - if self.count != count: - transformed = True - self.count = count - else: - transformed = False - - response = { - 'cached_until': time() + self.cache_timeout, - 'transformed': transformed - } - if self.hide_when_none and count == 0: - response['full_text'] = '' - else: - response['full_text'] = self.format.format(count) - - return response diff --git a/py3status/modules/scratchpad_counter.py b/py3status/modules/scratchpad_counter.py new file mode 100644 index 0000000..0b2eec7 --- /dev/null +++ b/py3status/modules/scratchpad_counter.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +""" +Module showing amount of windows at the scratchpad. + +@author shadowprince +@license Eclipse Public License +""" + +import i3 +from time import time + + +def find_scratch(tree): + if tree["name"] == "__i3_scratch": + return tree + else: + for x in tree["nodes"]: + result = find_scratch(x) + if result: + return result + return None + + +class Py3status: + + # available configuration parameters + cache_timeout = 5 + format = "{} ⌫" # format of indicator. {} replaces with count of windows + hide_when_none = False # hide indicator when there is no windows + + def __init__(self): + self.count = -1 + + def scratchpad_counter(self, i3s_output_list, i3s_config): + count = len(find_scratch(i3.get_tree()).get("floating_nodes", [])) + + if self.count != count: + transformed = True + self.count = count + else: + transformed = False + + response = { + 'cached_until': time() + self.cache_timeout, + 'transformed': transformed + } + if self.hide_when_none and count == 0: + response['full_text'] = '' + else: + response['full_text'] = self.format.format(count) + + return response -- cgit v1.3