diff options
| author | Ultrabug <ultrabug@gentoo.org> | 2014-12-21 20:12:02 +0100 |
|---|---|---|
| committer | Ultrabug <ultrabug@gentoo.org> | 2014-12-21 20:12:02 +0100 |
| commit | e5f854fdd80a69bd711f5af08a166f8cbc80db94 (patch) | |
| tree | f97ff11871e723ca0ab48773e9da535b56b245b8 /py3status/modules/keyboard-layout.py | |
| parent | 49c3bdd63027c44b0de9700f2d0e6f52776e1063 (diff) | |
module keyboard_layout name normalization and QA and config
Diffstat (limited to 'py3status/modules/keyboard-layout.py')
| -rw-r--r-- | py3status/modules/keyboard-layout.py | 73 |
1 files changed, 0 insertions, 73 deletions
diff --git a/py3status/modules/keyboard-layout.py b/py3status/modules/keyboard-layout.py deleted file mode 100644 index 1ed3cee..0000000 --- a/py3status/modules/keyboard-layout.py +++ /dev/null @@ -1,73 +0,0 @@ -from subprocess import check_output -from time import time - -""" -Module for showing current keyboard layout. - -Requires: - - xkblayout-state - or - - setxkbmap - -@author shadowprince -@license Eclipse Public License -""" - -CACHE_TIMEOUT = 10 # refresh time to update indicator - -# colors of layouts, check your command's output to match keys -LANG_COLORS = { - 'fr': '#268BD2', # solarized blue - 'ru': '#F75252', # red - 'ua': '#FCE94F', # yellow - 'us': '#729FCF', # light blue -} - - -def xbklayout(): - """ - check using xkblayout-state (preferred method) - """ - return check_output( - ["xkblayout-state", "print", "%s"] - ).decode('utf-8') - - -def setxkbmap(): - """ - check using setxkbmap >= 1.3.0 - - Please read issue 33 for more information : - https://github.com/ultrabug/py3status/pull/33 - """ - q = check_output(['setxkbmap', '-query']).decode('utf-8') - return q.replace(' ', '').split(':')[-1] - - -class Py3status: - def __init__(self): - """ - find the best implementation to get the keyboard's layout - """ - try: - xbklayout() - except: - self.command = setxkbmap - else: - self.command = xbklayout - - def keyboard_layout(self, i3status_output_json, i3status_config): - response = { - 'full_text': '', - 'name': 'keyboard-layout', - 'cached_until': time() + CACHE_TIMEOUT - } - - lang = self.command().strip() - lang_color = LANG_COLORS.get(lang) - - response['full_text'] = lang or '??' - if lang_color: - response['color'] = lang_color - - return (0, response) |
