diff options
| author | Vasiliy Horbachenko <shadowprince47@gmail.com> | 2014-05-22 17:03:09 +0300 |
|---|---|---|
| committer | Vasiliy Horbachenko <shadowprince47@gmail.com> | 2014-05-22 17:03:09 +0300 |
| commit | ab38f5686d6c0c2fa658743e4e0d18ae0f7af76e (patch) | |
| tree | 19eaffdd12e72b819c46a9fccd0527efce5cd7d6 /modules/current-keyboard-layout.py | |
| parent | 73f27f48731f213396bc1e206a26f176986c8fdc (diff) | |
added battery level, current keyboard layout
Diffstat (limited to 'modules/current-keyboard-layout.py')
| -rw-r--r-- | modules/current-keyboard-layout.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/modules/current-keyboard-layout.py b/modules/current-keyboard-layout.py new file mode 100644 index 0000000..046a2aa --- /dev/null +++ b/modules/current-keyboard-layout.py @@ -0,0 +1,33 @@ +import subprocess +import time + +""" +Module for showing current keyboard layout. +DEPENDS ON xkblayout-state! + +@author shadowprince +@version 1.0 +@license Eclipse Public License +""" + +CACHE_TIME = 0.2 # maximum time to update indicator + +# colors of layouts +# key must be compatible with xkblayout-state print %s! +LANG_COLORS = { + "ru": "#F75252", + "us": "#729FCF", + "ua": "#FCE94F", + } + +class Py3status: + def currentLayout(self, i3status_output_json, i3status_config): + response = {'full_text': '', 'name': 'current-layout', 'cached_until': time.time()+CACHE_TIME} + lang = subprocess.check_output(["xkblayout-state", "print", "%s"]).decode('utf-8') + + return (0, { + "full_text": lang, + "name": "current-layout", + "cached_until": time.time() + CACHE_TIME, + "color": LANG_COLORS.get(lang, "#ffffff"), + }) |
