summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorVasiliy Horbachenko <shadowprince47@gmail.com>2014-05-22 16:38:15 +0300
committerVasiliy Horbachenko <shadowprince47@gmail.com>2014-05-22 16:38:15 +0300
commit73f27f48731f213396bc1e206a26f176986c8fdc (patch)
tree5c6e32d80e0e13d47b5ecd662de0c46a4aa2c0ba /modules
parent3beaf88e9764e26725ab2cd2dfbe5c08ec61340e (diff)
scratchpad counter and current title fixes
Diffstat (limited to 'modules')
-rw-r--r--modules/current-title.py14
-rw-r--r--modules/scratchpad-counter.py2
-rw-r--r--modules/x/current-title.py44
3 files changed, 9 insertions, 51 deletions
diff --git a/modules/current-title.py b/modules/current-title.py
index 1f0822d..d8cf383 100644
--- a/modules/current-title.py
+++ b/modules/current-title.py
@@ -15,6 +15,7 @@ CONFIG:
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.
"""
+POSITION = 0
MAX_WIDTH = 120
CACHED_TIME = 0.5
@@ -36,7 +37,7 @@ class Py3status:
self.text = ""
super(Py3status).__init__(*args, **kwargs)
- def currentTitle(self, json, i3status_config):
+ def currentTitle(self, i3_status_output_json, i3status_config):
window = find_focused(i3.get_tree())
transformed = False
@@ -44,8 +45,9 @@ class Py3status:
self.text = len(window["name"]) > MAX_WIDTH and "..." + window["name"][-(MAX_WIDTH-3):] or window["name"]
transformed = True
- return (0, {'full_text': self.text,
- 'transformed': transformed,
- 'name': 'current-title',
- 'cached_until': time.time() + CACHED_TIME,
- })
+ return (POSITION, {
+ 'full_text': self.text,
+ 'transformed': transformed,
+ 'name': 'current-title',
+ 'cached_until': time.time() + CACHED_TIME,
+ })
diff --git a/modules/scratchpad-counter.py b/modules/scratchpad-counter.py
index 5fc3c71..f2c7dbc 100644
--- a/modules/scratchpad-counter.py
+++ b/modules/scratchpad-counter.py
@@ -24,7 +24,7 @@ class Py3status:
self.count = -1
super(Py3status).__init__(*args, **kwargs)
- def currentTitle(self, json, i3status_config):
+ def scratchpadCounter(self, i3status_output_json, i3status_config):
count = len(find_scratch(i3.get_tree()).get("floating_nodes", []))
if self.count != count:
diff --git a/modules/x/current-title.py b/modules/x/current-title.py
deleted file mode 100644
index 16248d1..0000000
--- a/modules/x/current-title.py
+++ /dev/null
@@ -1,44 +0,0 @@
-import i3
-import time
-
-"""
-Shows current window title.
-
-DEPENDENCIES:
- Depends on i3-py!
- pip install i3-py
-
-CONFIG:
- MAX_WIDTH - max title width
- CACHED_TIME - in seconds
-
-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.
-"""
-
-MAX_WIDTH = 120
-CACHED_TIME = 0.5
-
-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 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"]
-
- return (0, {'full_text': text,
- 'name': 'current-title',
- 'cached_until': time.time() + CACHED_TIME,
- })