From d9747b64e1e62abee12ef0bafd365cf380ff7fe9 Mon Sep 17 00:00:00 2001 From: Ultrabug Date: Sun, 23 Nov 2014 20:55:53 +0100 Subject: move modules folder so we can install it as a module of py3status --- modules/window-title.py | 58 ------------------------------------------------- 1 file changed, 58 deletions(-) delete mode 100644 modules/window-title.py (limited to 'modules/window-title.py') diff --git a/modules/window-title.py b/modules/window-title.py deleted file mode 100644 index 4f6f062..0000000 --- a/modules/window-title.py +++ /dev/null @@ -1,58 +0,0 @@ -import i3 -from time import time - -""" -Py3status plugin - shows current window title. - -Requires: - - i3-py (https://github.com/ziberna/i3-py) - # pip install i3-py - -If payload from server contains wierd utf-8 -(for example one window have something bad in title) - the plugin will -give empty output UNTIL this window is closed. -I can't fix or workaround that in PLUGIN, problem is in i3-py library. - -@author shadowprince -@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 - - -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): - self.text = '' - - def window_title(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 - - response = { - 'cached_until': time() + CACHE_TIMEOUT, - 'full_text': self.text, - 'name': 'window-title', - 'transformed': transformed - } - - return (POSITION, response) -- cgit v1.3