diff options
| author | Ultrabug <ultrabug@gentoo.org> | 2014-05-27 12:29:07 +0200 |
|---|---|---|
| committer | Ultrabug <ultrabug@gentoo.org> | 2014-05-27 12:29:07 +0200 |
| commit | a818e91ed70bb50eb2e05fd162d6d62cc150c546 (patch) | |
| tree | faf478fdce6947c2a85c7377cefe3df5a1a84006 /modules/current-title.py | |
| parent | 509506c4a89cab9863a25bb3e74bc10e64c0be53 (diff) | |
PEP8 and rename the current-title to window-title, normalization
Diffstat (limited to 'modules/current-title.py')
| -rw-r--r-- | modules/current-title.py | 52 |
1 files changed, 0 insertions, 52 deletions
diff --git a/modules/current-title.py b/modules/current-title.py deleted file mode 100644 index 530908f..0000000 --- a/modules/current-title.py +++ /dev/null @@ -1,52 +0,0 @@ -import i3 -import time - -""" -Py3status plugin - shows current window title. - -DEPENDENCIES: Depends on i3-py: - # pip install i3-py - -If payload from server contains wierd utf-8 (for example one window have something bad in title) - plugin will give empty output UNTIL this window will be closed. I can't fix or workaround that in PLUGIN, problem is in i3-py library. - -@author shadowprince -@version 1.0 -@license Eclipse Public License -""" - -POSITION = 0 -MAX_WIDTH = 120 # if width of title is greater, shrink it and add ... -CACHED_TIME = 0.5 # maximum time to update indicator - -def find_focused(tree): - if type(tree) == list: - for el in tree: - res = find_focused(el) - if res: - return res - - elif type(tree) == dict: - if tree["focused"]: - return tree - else: - return find_focused(tree["nodes"] + tree["floating_nodes"]) - -class Py3status: - def __init__(self, *args, **kwargs): - self.text = "" - super(Py3status).__init__(*args, **kwargs) - - def currentTitle(self, i3_status_output_json, i3status_config): - window = find_focused(i3.get_tree()) - - 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"] - transformed = True - - return (POSITION, { - 'full_text': self.text, - 'transformed': transformed, - 'name': 'current-title', - 'cached_until': time.time() + CACHED_TIME, - }) |
