From 8aeeed0c8149cba043404528a06fcf32b372372e Mon Sep 17 00:00:00 2001 From: Stefan Pricopie Date: Tue, 28 Oct 2025 14:42:37 +0200 Subject: [PATCH 1/2] Add TTY switching support for Chromebook keyboards Enable Ctrl+Alt+F1-F8 TTY switching for both keyboard modes: - Inverted mode: F-keys map directly to TTY switches - Non-inverted mode: Chrome keys (back/forward/refresh/etc) map to TTY switches This allows proper virtual console access on Chromebooks running Linux, which is essential for troubleshooting, recovery, and server management. --- cros-keyboard-map.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/cros-keyboard-map.py b/cros-keyboard-map.py index 744081b..78cf104 100644 --- a/cros-keyboard-map.py +++ b/cros-keyboard-map.py @@ -157,6 +157,24 @@ def get_keyd_config(physmap, inverted): [control+alt] backspace = C-A-delete +# TTY switching for inverted mode (F-keys by default) +f1 = C-A-f1 +f2 = C-A-f2 +f3 = C-A-f3 +f4 = C-A-f4 +f5 = C-A-f5 +f6 = C-A-f6 +f7 = C-A-f7 +f8 = C-A-f8 +# TTY switching for non-inverted mode (Chrome keys by default) +back = C-A-f1 +forward = C-A-f2 +refresh = C-A-f3 +zoom = C-A-f4 +scale = C-A-f5 +brightnessdown = C-A-f6 +brightnessup = C-A-f7 +mute = C-A-f8 """ return config From 31e6b9a9908c512ff33e79afc4782c9d48316124 Mon Sep 17 00:00:00 2001 From: Stefan Pricopie Date: Sat, 1 Nov 2025 15:12:25 +0200 Subject: [PATCH 2/2] feat(keyboard): dynamically generate TTY switching mappings - Add get_tty_switching() function to generate mappings based on physmap - Remove hardcoded key mappings (brightnessdown, brightnessup, mute) - Support all top row keys dynamically (10-12 keys vs previous 8) - Ensure compatibility with all Chromebook vivaldi keyboard layouts - Works for both inverted and non-inverted keyboard modes --- cros-keyboard-map.py | 46 +++++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/cros-keyboard-map.py b/cros-keyboard-map.py index 78cf104..e8ea14d 100644 --- a/cros-keyboard-map.py +++ b/cros-keyboard-map.py @@ -122,6 +122,33 @@ def get_functional_row(physmap, use_vivaldi, super_is_held, super_inverted): return result +def get_tty_switching(physmap): + """Generate TTY switching mappings for all top row keys. + + Dynamically generates Ctrl+Alt+F{n} mappings based on the actual physmap, + ensuring compatibility with all Chromebook keyboard layouts. + """ + arch = get_arch() + if arch != "x86_64": + arch = "arm" + + i = 0 + result = "" + + # Generate F-key mappings for inverted mode (F-keys by default) + for code in physmap: + i += 1 + result += f"f{i} = C-A-f{i}\n" + + # Generate Chrome key mappings for non-inverted mode (Chrome keys by default) + i = 0 + for code in physmap: + i += 1 + chrome_key = vivaldi_keys[arch][code] + result += f"{chrome_key} = C-A-f{i}\n" + + return result + def get_keyd_config(physmap, inverted): config = f"""\ [ids] @@ -157,24 +184,7 @@ def get_keyd_config(physmap, inverted): [control+alt] backspace = C-A-delete -# TTY switching for inverted mode (F-keys by default) -f1 = C-A-f1 -f2 = C-A-f2 -f3 = C-A-f3 -f4 = C-A-f4 -f5 = C-A-f5 -f6 = C-A-f6 -f7 = C-A-f7 -f8 = C-A-f8 -# TTY switching for non-inverted mode (Chrome keys by default) -back = C-A-f1 -forward = C-A-f2 -refresh = C-A-f3 -zoom = C-A-f4 -scale = C-A-f5 -brightnessdown = C-A-f6 -brightnessup = C-A-f7 -mute = C-A-f8 +{get_tty_switching(physmap)} """ return config