summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--modules/scratchpad-counter.py37
1 files changed, 19 insertions, 18 deletions
diff --git a/modules/scratchpad-counter.py b/modules/scratchpad-counter.py
index b1cdd73..390745f 100644
--- a/modules/scratchpad-counter.py
+++ b/modules/scratchpad-counter.py
@@ -1,20 +1,20 @@
+# -*- coding: utf-8 -*-
+
import i3
-import time
-import random
-from pprint import pprint
+from time import time
"""
Module showing amount of windows at the scratchpad.
@author shadowprince
-@version 1.0
@license Eclipse Public License
"""
-CACHED_TIME = 1
-POSITION = 1
-HIDE_WHEN_NONE = True # hide indicator when there is no windows
-STRFORMAT = "{} ⌫" # format of indicator. {} replaces with count of windows
+CACHE_TIMEOUT = 5
+HIDE_WHEN_NONE = False # hide indicator when there is no windows
+POSITION = 0
+STRFORMAT = "{} ⌫" # format of indicator. {} replaces with count of windows
+
def find_scratch(tree):
if tree["name"] == "__i3_scratch":
@@ -24,15 +24,14 @@ def find_scratch(tree):
result = find_scratch(x)
if result:
return result
-
return None
+
class Py3status:
- def __init__(self, *args, **kwargs):
+ def __init__(self):
self.count = -1
- super(Py3status).__init__(*args, **kwargs)
- def scratchpadCounter(self, i3status_output_json, i3status_config):
+ def scratchpad_counter(self, i3status_output_json, i3status_config):
count = len(find_scratch(i3.get_tree()).get("floating_nodes", []))
if self.count != count:
@@ -41,9 +40,11 @@ class Py3status:
else:
transformed = False
- return (POSITION, {
- 'transformed': transformed,
- 'full_text': '' if HIDE_WHEN_NONE and count == 0 else STRFORMAT.format(count),
- 'name': 'scratchpad-count',
- 'cached_until': time.time() + CACHED_TIME,
- })
+ response = {
+ 'cached_until': time() + CACHE_TIMEOUT,
+ 'full_text': '' if HIDE_WHEN_NONE and count == 0 else STRFORMAT.format(count),
+ 'name': 'scratchpad-counter',
+ 'transformed': transformed
+ }
+
+ return (POSITION, response)