diff options
| author | Ultrabug <ultrabug@gentoo.org> | 2014-12-04 19:24:52 +0100 |
|---|---|---|
| committer | Ultrabug <ultrabug@gentoo.org> | 2014-12-04 19:24:52 +0100 |
| commit | 6881f3c873ce733336c0c2ee6ae13e0bc928898f (patch) | |
| tree | f3f6af7fda84cb0e7d48018bbc94e43fb56808fe /py3status | |
| parent | e8f0c53c91f5bb8c2c7207a4fbd7fcf727b5bd76 (diff) | |
module window-title QA and config
Diffstat (limited to 'py3status')
| -rw-r--r-- | py3status/modules/window-title.py | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/py3status/modules/window-title.py b/py3status/modules/window-title.py index 4f6f062..5096bd3 100644 --- a/py3status/modules/window-title.py +++ b/py3status/modules/window-title.py @@ -1,6 +1,3 @@ -import i3 -from time import time - """ Py3status plugin - shows current window title. @@ -17,9 +14,8 @@ I can't fix or workaround that in PLUGIN, problem is in i3-py library. @license Eclipse Public License """ -CACHE_TIMEOUT = 0.5 # maximum time to update indicator -MAX_WIDTH = 120 # if width of title is greater, shrink it and add '...' -POSITION = 0 +import i3 +from time import time def find_focused(tree): @@ -28,7 +24,6 @@ def find_focused(tree): res = find_focused(el) if res: return res - elif type(tree) == dict: if tree['focused']: return tree @@ -37,6 +32,11 @@ def find_focused(tree): class Py3status: + + # available configuration parameters + cache_timeout = 0.5 + max_width = 120 # if width of title is greater, shrink it and add '...' + def __init__(self): self.text = '' @@ -45,14 +45,16 @@ class Py3status: transformed = False if window and 'name' in window and window['name'] != self.text: - self.text = len(window['name']) > MAX_WIDTH and "..." + window['name'][-(MAX_WIDTH-3):] or window['name'] + self.text = ( + len(window['name']) > self.max_width + and "..." + window['name'][-(self.max_width-3):] + or window['name'] + ) transformed = True response = { - 'cached_until': time() + CACHE_TIMEOUT, + 'cached_until': time() + self.cache_timeout, 'full_text': self.text, - 'name': 'window-title', 'transformed': transformed } - - return (POSITION, response) + return response |
