From 94c99351d72b91c3f6063fac3c98001ed893b3cd Mon Sep 17 00:00:00 2001 From: Vasiliy Horbachenko Date: Tue, 20 May 2014 11:09:34 +0300 Subject: current-title: updated --- modules/current-title.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/modules/current-title.py b/modules/current-title.py index ad2b97a..1f0822d 100644 --- a/modules/current-title.py +++ b/modules/current-title.py @@ -32,13 +32,20 @@ def find_focused(tree): 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, json, i3status_config): window = find_focused(i3.get_tree()) - if window and "name" in window: - text = len(window["name"]) > MAX_WIDTH and "..." + window["name"][-(MAX_WIDTH-3):] or window["name"] + 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 (0, {'full_text': text, + return (0, {'full_text': self.text, + 'transformed': transformed, 'name': 'current-title', 'cached_until': time.time() + CACHED_TIME, }) -- cgit v1.3