From a0763e0442c998db9f71074b35ba9a3376357bae Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Thu, 6 Mar 2014 23:30:51 +0100 Subject: fix and use xkb lock keys MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- examples/plugin-test | 9 +++++++-- src/plugins/xkb.py | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/examples/plugin-test b/examples/plugin-test index a012542..5c5d84a 100644 --- a/examples/plugin-test +++ b/examples/plugin-test @@ -18,6 +18,7 @@ from plugins.moc import MOC from plugins.cpu import CPU from plugins.clock import Clock from plugins.network import Network +from plugins.xkb import XKB OUTPUT, HEIGHT, YPOS, TOP = 0, 3 * 12, 24, True @@ -187,14 +188,18 @@ def redraw(): net_total = '%.2fGB|%.2fGB' % (sum([rx for _, rx, tx in net_]), sum([tx for _, rx, tx in net_])) net = '%s : %s' % (' '.join(net_each), net_total) + xkb_ = XKB() + locks = ' '.join([x.lower() for x in xkb_.get_locks_str()]) + xkb = 'Xkb:%s' % ('' if len(locks) == 0 else ' ' + locks) + text = ['%s │ %s │ %s │ %s │ %s │ %s %s │ %s │ %s │ %s │ %s' ,'%s │ %s │ %s' - ,'%s'] + ,'%s │ %s'] text = '\n'.join(text) text %= (date, uptime, idle, loadavg, users, uname, xdisplay, mem, swp, shm, moc, discs, discstats, cpu, - net) + net, xkb) bar.clear() bar.draw_coloured_text(0, 10, 0, 2, text) diff --git a/src/plugins/xkb.py b/src/plugins/xkb.py index 362dba0..004f1bf 100644 --- a/src/plugins/xkb.py +++ b/src/plugins/xkb.py @@ -50,7 +50,7 @@ class XKB: ''' self.__root = get_screen().root - lockkey = lambda lock : self.__display.keysym_to_keycode(Xlib.XK.string_to_keysym(lock + '_Lock')) + lockkey = lambda lock : get_display().keysym_to_keycode(Xlib.XK.string_to_keysym(lock + '_Lock')) find = lambda array, item : (1 << array.index(item)) if item in array else -1 mods = [x[0] for x in get_display().get_modifier_mapping()] -- cgit v1.2.3-70-g09d2