Skip to content

Commit

Permalink
gui: set xkb_layout manually
Browse files Browse the repository at this point in the history
  • Loading branch information
fepitre committed Feb 25, 2020
1 parent 65238c1 commit a67b8f3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
21 changes: 9 additions & 12 deletions qubes/ext/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -81,16 +79,15 @@ def on_domain_qdb_create(self, vm, event):
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')
Expand Down
9 changes: 8 additions & 1 deletion qubes/tests/vm/qubesvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1833,6 +1833,13 @@ def test_622_qdb_keyboard_layout(self, mock_qubesdb, mock_urandom,
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
Expand All @@ -1843,7 +1850,7 @@ def test_622_qdb_keyboard_layout(self, mock_qubesdb, mock_urandom,
'/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),
Expand Down

0 comments on commit a67b8f3

Please sign in to comment.