set xkb kb to us before test

This commit is contained in:
glasseyes 2018-12-13 11:53:56 +07:00
parent 4af0250dd2
commit 24e488817a
2 changed files with 34 additions and 2 deletions

View file

@ -29,6 +29,21 @@ tests=(
#for test in ${tests}; do echo "$test"; done
model=`setxkbmap -query|grep model|cut -d ':' -f 2|tr -d ' '`
layout=`setxkbmap -query|grep layout|cut -d ':' -f 2|tr -d ' '`
rules=`setxkbmap -query|grep rules|cut -d ':' -f 2|tr -d ' '`
variant=`setxkbmap -query|grep variant|cut -d ':' -f 2|tr -d ' '`
echo "System xkb keyboard"
echo "model:$model"
echo "layout:$layout"
echo "rules:$rules"
echo "variant:$variant"
echo "Setting keyboard to us"
setxkbmap us
setxkbmap -query
count=0
passed=0
failed=0
@ -48,7 +63,16 @@ do
count=$(( $count + 1 ))
done
echo "Setting xkb keyboard back to system one"
if [ "x$variant" == "x" ]; then
setxkbmap -model $model -layout $layout -rules $rules
else
setxkbmap -model $model -layout $layout -rules $rules -variant $variant
fi
setxkbmap -query
echo "-----------------------------------------------------"
echo "Tests run : ${count}"
echo "Passed : ${passed}"
echo "Failed : ${failed}"

View file

@ -8,6 +8,12 @@ import time
from pynput.keyboard import Key, Controller
try:
from xkbgroup import XKeyboard
has_xkbgroup = True
except:
has_xkbgroup = False
gi.require_version('Gtk', '3.0')
gi.require_version('Gdk', '3.0')
from gi.repository import Gtk, Gdk, Gio
@ -20,12 +26,11 @@ class TestView(Gtk.Window):
def __init__(self, test_name):
Gtk.Window.__init__(self, title=test_name)
self.known_modifiers = { "SHIFT" : Key.shift,
"LCTRL" : Key.ctrl_l,
"RCTRL" : Key.ctrl_r,
"LALT" : Key.alt,
"RALT" : Key.alt_gr }
"RALT" : Key.alt_r }
self.known_keys = { "K_A" : "a",
"K_B" : "b",
"K_C" : "c",
@ -76,6 +81,9 @@ class TestView(Gtk.Window):
def do_keypresses(self, args, data):
if self.keys and not self.haspressedkeys:
if has_xkbgroup:
with XKeyboard() as xkb:
logging.info("xkb %d:%s:%s", xkb.group_num, xkb.group_symbol, xkb.group_name)
localkeyboard = Controller()
keys = self.keys.split("]")
# print(keys)