gui: set xkb_layout manually

This commit is contained in:
Frédéric Pierret (fepitre) 2020-02-25 11:09:53 +01:00
parent 65238c187f
commit a67b8f35ba
No known key found for this signature in database
GPG Key ID: 484010B5CDC576E2
2 changed files with 17 additions and 13 deletions

View File

@ -21,8 +21,6 @@
# License along with this library; if not, see <https://www.gnu.org/licenses/>.
#
import subprocess
import qubes.config
import qubes.ext
@ -81,16 +79,15 @@ class GUI(qubes.ext.Extension):
if kbd_layout:
vm.untrusted_qdb.write('/keyboard-layout', kbd_layout)
# Legacy value for setting keyboard layout
try:
xkb_keymap = subprocess.run(['/usr/bin/setxkbmap', '-print'],
stdout=subprocess.PIPE,
check=False)
if xkb_keymap.stdout:
vm.untrusted_qdb.write('/qubes-keyboard', xkb_keymap.stdout)
except FileNotFoundError:
# Prevent any reason for 'setxkbmap' being not present
pass
# Legacy value for setting keyboard layout
xkb_keymap = \
'xkb_keymap {\x0a\x09xkb_keycodes { include ' \
'"evdev"\x09};\x0a\x09xkb_types { include ' \
'"complete"\x09};\x0a\x09xkb_compat { include ' \
'"complete"\x09};\x0a\x09xkb_symbols { include ' \
'"pc+%s+inet(evdev)"\x09};\x0a\x09xkb_geometry ' \
'{ include "pc(pc105)"\x09};\x0a};' % kbd_layout
vm.untrusted_qdb.write('/qubes-keyboard', xkb_keymap)
# Set GuiVM prefix
guivm_windows_prefix = vm.features.get('guivm-windows-prefix', 'GuiVM')

View File

@ -1833,6 +1833,13 @@ class TC_90_QubesVM(QubesVMTestsMixin, qubes.tests.QubesTestCase):
vm.netvm = None
vm.guivm = guivm
guivm.features['keyboard-layout'] = 'fr'
xkb_keymap = \
'xkb_keymap {\x0a\x09xkb_keycodes { include ' \
'"evdev"\x09};\x0a\x09xkb_types { include ' \
'"complete"\x09};\x0a\x09xkb_compat { include ' \
'"complete"\x09};\x0a\x09xkb_symbols { include ' \
'"pc+fr+inet(evdev)"\x09};\x0a\x09xkb_geometry ' \
'{ include "pc(pc105)"\x09};\x0a};'
vm.events_enabled = True
test_qubesdb = TestQubesDB()
mock_qubesdb.write.side_effect = test_qubesdb.write
@ -1843,7 +1850,7 @@ class TC_90_QubesVM(QubesVMTestsMixin, qubes.tests.QubesTestCase):
'/name': 'test-inst-appvm',
'/type': 'AppVM',
'/default-user': 'user',
'/qubes-keyboard': unittest.mock.ANY,
'/qubes-keyboard': xkb_keymap,
'/keyboard-layout': 'fr',
'/qubes-vm-type': 'AppVM',
'/qubes-gui-domain-xid': '{}'.format(guivm.xid),