[modules/layout-xkb] Gracefully handle missing xkbgroup library

Show "n/a" is xkbgroup is not installed/available

see #177
This commit is contained in:
Tobias Witek 2017-10-01 05:45:52 +02:00
parent e0e59b863c
commit 7c17516874

View file

@ -13,7 +13,11 @@ import bumblebee.input
import bumblebee.output
import bumblebee.engine
has_xkb = True
try:
from xkbgroup import *
except ImportError:
has_xkb = False
import logging
log = logging.getLogger(__name__)
@ -35,6 +39,8 @@ class Module(bumblebee.engine.Module):
self._set_keymap(-1)
def _set_keymap(self, rotation):
if not has_xkb: return
xkb = XKeyboard()
if xkb.groups_count < 2: return # nothing to doA