From e39f2804056932142a5aaad1c2621d8658fcd7d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Pierret=20=28fepitre=29?= Date: Sat, 28 Mar 2020 10:06:50 +0100 Subject: [PATCH] qvm-start-daemon: check if layout is parsed --- qubesadmin/tools/qvm_start_daemon.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/qubesadmin/tools/qvm_start_daemon.py b/qubesadmin/tools/qvm_start_daemon.py index edb4db3..c3c2af5 100644 --- a/qubesadmin/tools/qvm_start_daemon.py +++ b/qubesadmin/tools/qvm_start_daemon.py @@ -127,11 +127,14 @@ def set_keyboard_layout(vm): xkb_rules_names = subprocess.check_output( ['xprop', '-root', '_XKB_RULES_NAMES']).decode() xkb_parsed = re.match(xkb_re, xkb_rules_names) - xkb_layout = [x.split(',')[0] for x in xkb_parsed.groups()[2:4]] - # We keep all options - xkb_layout.append(xkb_parsed.group(5)) - keyboard_layout = '+'.join(xkb_layout) - vm.features['keyboard-layout'] = keyboard_layout + if xkb_parsed: + xkb_layout = [x.split(',')[0] for x in xkb_parsed.groups()[2:4]] + # We keep all options + xkb_layout.append(xkb_parsed.group(5)) + keyboard_layout = '+'.join(xkb_layout) + vm.features['keyboard-layout'] = keyboard_layout + else: + vm.log.warning('Failed to parse layout for %s', vm) except subprocess.CalledProcessError as e: vm.log.warning('Failed to set layout for %s: %s', vm, str(e))