Change keyboard layout (not done yet)

This commit is contained in:
Milos Miljanic 2016-11-26 12:33:42 +01:00
parent 3dd595477f
commit 59c0083fc4

View file

@ -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