Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions cros-keyboard-map.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -157,6 +184,7 @@ def get_keyd_config(physmap, inverted):

[control+alt]
backspace = C-A-delete
{get_tty_switching(physmap)}
"""
return config

Expand Down