summaryrefslogtreecommitdiffstats
path: root/py3status
diff options
context:
space:
mode:
authorUltrabug <ultrabug@gentoo.org>2014-12-21 20:12:02 +0100
committerUltrabug <ultrabug@gentoo.org>2014-12-21 20:12:02 +0100
commite5f854fdd80a69bd711f5af08a166f8cbc80db94 (patch)
treef97ff11871e723ca0ab48773e9da535b56b245b8 /py3status
parent49c3bdd63027c44b0de9700f2d0e6f52776e1063 (diff)
module keyboard_layout name normalization and QA and config
Diffstat (limited to 'py3status')
-rw-r--r--py3status/modules/keyboard_layout.py (renamed from py3status/modules/keyboard-layout.py)33
1 files changed, 23 insertions, 10 deletions
diff --git a/py3status/modules/keyboard-layout.py b/py3status/modules/keyboard_layout.py
index 1ed3cee..ffc3907 100644
--- a/py3status/modules/keyboard-layout.py
+++ b/py3status/modules/keyboard_layout.py
@@ -1,6 +1,4 @@
-from subprocess import check_output
-from time import time
-
+# -*- coding: utf-8 -*-
"""
Module for showing current keyboard layout.
@@ -13,7 +11,8 @@ Requires:
@license Eclipse Public License
"""
-CACHE_TIMEOUT = 10 # refresh time to update indicator
+from subprocess import check_output
+from time import time
# colors of layouts, check your command's output to match keys
LANG_COLORS = {
@@ -45,6 +44,11 @@ def setxkbmap():
class Py3status:
+
+ # available configuration parameters
+ cache_timeout = 10
+ color = ''
+
def __init__(self):
"""
find the best implementation to get the keyboard's layout
@@ -56,18 +60,27 @@ class Py3status:
else:
self.command = xbklayout
- def keyboard_layout(self, i3status_output_json, i3status_config):
+ def keyboard_layout(self, i3s_output_list, i3s_config):
response = {
- 'full_text': '',
- 'name': 'keyboard-layout',
- 'cached_until': time() + CACHE_TIMEOUT
+ 'cached_until': time() + self.cache_timeout,
+ 'full_text': ''
}
lang = self.command().strip()
- lang_color = LANG_COLORS.get(lang)
+ lang_color = self.color if self.color else LANG_COLORS.get(lang)
response['full_text'] = lang or '??'
if lang_color:
response['color'] = lang_color
- return (0, response)
+ return response
+
+if __name__ == "__main__":
+ """
+ Test this module by calling it directly.
+ """
+ from time import sleep
+ x = Py3status()
+ while True:
+ print(x.keyboard_layout([], {}))
+ sleep(1)