[modules/layout-xkb] Use set-xkbmap to switch layouts

Use the data retrieved via xkb and set the new layouts and variants
using set-xkbmap.

see #177
This commit is contained in:
Tobias Witek 2017-09-30 16:21:51 +02:00
parent a98c337cc6
commit ad4246d52d

View file

@ -32,6 +32,15 @@ class Module(bumblebee.engine.Module):
self._set_keymap(-1) self._set_keymap(-1)
def _set_keymap(self, rotation): def _set_keymap(self, rotation):
xkb = XKeyboard()
if xkb.groups_count < 2: return # nothing to doA
layouts = xkb.groups_symbols[rotation:] + xkb.groups_symbols[:rotation]
variants = xkb.groups_variants[rotation:] + xkb.groups_variants[:rotation]
try:
bumblebee.util.execute("setxkbmap -layout {} -variant {}".format(",".join(layouts), ",".join(variants)))
except RuntimeError:
pass pass
def current_layout(self, widget): def current_layout(self, widget):