diff options
author | Mattias Andrée <maandree@operamail.com> | 2014-03-06 22:53:43 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2014-03-06 22:53:43 +0100 |
commit | a4e1b876f0dd31d38d988ad34cc73beb4e50e55d (patch) | |
tree | f39fa5cb1cbb192f4af8ae532c4b345d2325c18b /src/plugins | |
parent | update todo (diff) | |
download | xpybar-a4e1b876f0dd31d38d988ad34cc73beb4e50e55d.tar.gz xpybar-a4e1b876f0dd31d38d988ad34cc73beb4e50e55d.tar.bz2 xpybar-a4e1b876f0dd31d38d988ad34cc73beb4e50e55d.tar.xz |
add XKB.get_locks_str
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r-- | src/plugins/xkb.py | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/plugins/xkb.py b/src/plugins/xkb.py index 40ecf8d..0bb3222 100644 --- a/src/plugins/xkb.py +++ b/src/plugins/xkb.py @@ -57,17 +57,31 @@ class XKB: self.__scroll = find(mods, lockkey('Scroll')) + # TODO add update listener def get_locks(self): ''' Get the currently active lock keys (num lock, caps lock and scroll lock, but not compose) @return :int The bitwise OR of the active lock keys (XKB.NUM, XKB.CAPS, XKB.SCROLL) ''' - # TODO add update listener mask = self.__root.query_pointer().mask rc = 0 rc |= XKB.NUM if (mask & self.__num) == self.__num else 0 rc |= XKB.CAPS if (mask & self.__caps) == self.__caps else 0 rc |= XKB.SCROLL if (mask & self.__scroll) == self.__scroll else 0 return rc + + + def get_locks_str(self): + ''' + Get the currently active lock keys (num lock, caps lock and scroll lock, but not compose) + + @return :list<str> A list of locks in title case ('Num', 'Caps', 'Scroll') + ''' + mask = self.__root.query_pointer().mask + rc = [] + if (mask & self.__num) == self.__num: rc.append('Num') + if (mask & self.__caps) == self.__caps: rc.append('Caps') + if (mask & self.__scroll) == self.__scroll: rc.append('Scroll') + return rc |