From a4e1b876f0dd31d38d988ad34cc73beb4e50e55d Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Thu, 6 Mar 2014 22:53:43 +0100 Subject: add XKB.get_locks_str MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/plugins/xkb.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src') 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 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 -- cgit v1.2.3-70-g09d2