[modules/layout] Update to latest API
This commit is contained in:
parent
20cab432b9
commit
985ad2edc8
1 changed files with 17 additions and 20 deletions
|
@ -6,25 +6,25 @@ Requires the following executable:
|
||||||
* setxkbmap
|
* setxkbmap
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import bumblebee.util
|
import core.module
|
||||||
import bumblebee.input
|
import core.widget
|
||||||
import bumblebee.output
|
import core.input
|
||||||
import bumblebee.engine
|
|
||||||
|
|
||||||
class Module(bumblebee.engine.Module):
|
import util.cli
|
||||||
def __init__(self, engine, config):
|
|
||||||
super(Module, self).__init__(engine, config,
|
|
||||||
bumblebee.output.Widget(full_text=self.current_layout)
|
|
||||||
)
|
|
||||||
engine.input.register_callback(self, button=bumblebee.input.LEFT_MOUSE,
|
|
||||||
cmd=self._next_keymap)
|
|
||||||
engine.input.register_callback(self, button=bumblebee.input.RIGHT_MOUSE,
|
|
||||||
cmd=self._prev_keymap)
|
|
||||||
|
|
||||||
def _next_keymap(self, event):
|
class Module(core.module.Module):
|
||||||
|
def __init__(self, config):
|
||||||
|
super().__init__(config, core.widget.Widget(self.current_layout))
|
||||||
|
|
||||||
|
core.input.register(self, button=core.input.LEFT_MOUSE,
|
||||||
|
cmd=self.__next_keymap)
|
||||||
|
core.input.register(self, button=core.input.RIGHT_MOUSE,
|
||||||
|
cmd=self.__prev_keymap)
|
||||||
|
|
||||||
|
def __next_keymap(self, event):
|
||||||
self._set_keymap(1)
|
self._set_keymap(1)
|
||||||
|
|
||||||
def _prev_keymap(self, event):
|
def __prev_keymap(self, event):
|
||||||
self._set_keymap(-1)
|
self._set_keymap(-1)
|
||||||
|
|
||||||
def _set_keymap(self, rotation):
|
def _set_keymap(self, rotation):
|
||||||
|
@ -39,14 +39,11 @@ class Module(bumblebee.engine.Module):
|
||||||
layout_list.append(tmp[0])
|
layout_list.append(tmp[0])
|
||||||
variant_list.append(tmp[1] if len(tmp) > 1 else '')
|
variant_list.append(tmp[1] if len(tmp) > 1 else '')
|
||||||
|
|
||||||
try:
|
util.cli.execute('setxkbmap -layout {} -variant {}'.format(','.join(layout_list), ','.join(variant_list)), ignore_errors=True)
|
||||||
bumblebee.util.execute('setxkbmap -layout {} -variant {}'.format(','.join(layout_list), ','.join(variant_list)))
|
|
||||||
except RuntimeError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
def get_layouts(self):
|
def get_layouts(self):
|
||||||
try:
|
try:
|
||||||
res = bumblebee.util.execute('setxkbmap -query')
|
res = util.cli.execute('setxkbmap -query')
|
||||||
except RuntimeError:
|
except RuntimeError:
|
||||||
return ['n/a']
|
return ['n/a']
|
||||||
layouts = []
|
layouts = []
|
||||||
|
|
Loading…
Reference in a new issue