Map keyboard choices to the layouts the installer sets
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
bcdcb11cfa
commit
7b260bed17
2 files changed
+15
-5
No files matched your search
@@ -23,12 +23,16 @@ def keyboard_catalog():
|
||||
layout = fields[1].split(",")[0]
|
||||
variant = fields[3].split(",")[0]
|
||||
mappings.setdefault(fields[0], layout + (":" + variant if variant != "-" else ""))
|
||||
# These console names have no entry in systemd's conversion table.
|
||||
mappings.update({"azerty": "az", "bg-cp1251": "bg", "colemak": "us:colemak", "kyrgyz": "kg",
|
||||
"de_CH-latin1": "ch", "no-latin1": "no"})
|
||||
# The console names systemd's table lacks convert as keyboard_xkb_settings in
|
||||
# omarchy-provision-owner does, so a choice types what it did at install.
|
||||
installer = {"azerty": "fr", "bg-cp1251": "bg:phonetic", "colemak": "us:colemak", "cz": "cz:qwerty",
|
||||
"kyrgyz": "kg", "de_CH-latin1": "ch", "no-latin1": "no"}
|
||||
mappings.update(installer)
|
||||
catalog = {}
|
||||
for choice in choices.splitlines():
|
||||
label, keymap, *input_settings = choice.split("|")
|
||||
rows = [choice.split("|") for choice in choices.splitlines()]
|
||||
# azerty is French AZERTY, so a converted keymap never renames a layout
|
||||
# another choice names directly.
|
||||
for label, keymap, *input_settings in sorted(rows, key=lambda row: row[1] in installer):
|
||||
layout = input_settings[1] if len(input_settings) > 1 else mappings.get(keymap, keymap)
|
||||
if label == "Lao":
|
||||
layout = "la"
|
||||
|
||||
@@ -30,6 +30,12 @@ class TypingSetupTest(unittest.TestCase):
|
||||
self.assertEqual(catalog["us:colemak"], "English (US, Colemak)")
|
||||
self.assertEqual(catalog["ch"], "German (Switzerland)")
|
||||
self.assertEqual(catalog["la"], "Lao")
|
||||
# Converted as the installer does, without renaming French.
|
||||
self.assertEqual(catalog["fr"], "French")
|
||||
self.assertEqual(catalog["bg:phonetic"], "Bulgarian")
|
||||
self.assertEqual(catalog["cz:qwerty"], "Czech")
|
||||
self.assertNotIn("az", catalog)
|
||||
self.assertEqual(catalog["latam"], "Spanish (Latin American)")
|
||||
self.assertEqual(catalog["latam"], "Spanish (Latin American)")
|
||||
self.assertNotIn("us:intl", catalog)
|
||||
self.assertLess(len(catalog), 60)
|
||||
|
||||
Reference in new issue
Block a user