diff options
| author | Vasiliy Horbachenko <shadowprince47@gmail.com> | 2014-05-22 08:08:40 +0300 |
|---|---|---|
| committer | Vasiliy Horbachenko <shadowprince47@gmail.com> | 2014-05-22 08:08:40 +0300 |
| commit | 3beaf88e9764e26725ab2cd2dfbe5c08ec61340e (patch) | |
| tree | bfce3d263406105699a205bf4e7d8226ab8fe259 /modules | |
| parent | 94c99351d72b91c3f6063fac3c98001ed893b3cd (diff) | |
added scratchpad-counter
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/scratchpad-counter.py | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/modules/scratchpad-counter.py b/modules/scratchpad-counter.py new file mode 100644 index 0000000..5fc3c71 --- /dev/null +++ b/modules/scratchpad-counter.py @@ -0,0 +1,41 @@ +import i3 +import time +import random +from pprint import pprint + +CACHED_TIME = 1 +POSITION = 1 +HIDE_WHEN_NONE = True +STRFORMAT = "{} ⌫" + +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: + def __init__(self, *args, **kwargs): + self.count = -1 + super(Py3status).__init__(*args, **kwargs) + + def currentTitle(self, json, i3status_config): + count = len(find_scratch(i3.get_tree()).get("floating_nodes", [])) + + if self.count != count: + transformed = True + self.count = count + 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, + }) |
