From 59c0083fc4debc274ecb168e17b80d3a2b0160c8 Mon Sep 17 00:00:00 2001 From: Milos Miljanic Date: Sat, 26 Nov 2016 12:33:42 +0100 Subject: [PATCH] Change keyboard layout (not done yet) --- bumblebee/modules/layout.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 bumblebee/modules/layout.py diff --git a/bumblebee/modules/layout.py b/bumblebee/modules/layout.py new file mode 100644 index 0000000..71649a5 --- /dev/null +++ b/bumblebee/modules/layout.py @@ -0,0 +1,36 @@ +import subprocess +import shlex +import bumblebee.module +import bumblebee.util + +def description(): + return "Showws current keyboard layout and change it on click." + +class Module(bumblebee.module.Module): + def __init__(self, output, config, alias): + super(Module, self).__init__(output, config, alias) + + + # click + output.add_callback(module="layout.cir", button=1, cmd="setxkbmap us") + output.add_callback(module="layout.us", button=1, cmd="setxkbmap rs") + output.add_callback(module="layout.rs", button=1, cmd="setxkbmap -layout rs -variant latin") + + + + + def widgets(self): + output = subprocess.check_output(["setxkbmap", "-print"], stderr=subprocess.STDOUT) + for line in str(output).split("\\n"): + if "xkb_symbols" in line: + res = line.split("\"")[1].split("+")[1] + + if res == "rs": + return bumblebee.output.Widget(self, res, instance="layout.rs") + elif res == "us": + return bumblebee.output.Widget(self, res, instance="layout.us") + else: + return bumblebee.output.Widget(self, res, instance="layout.cir") + + +# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4