Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions default/i18n/en/cli.json
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@
"hermes.deleteData": "Also delete ~/.hermes and ~/.config/Hermes (%1: chats, memories, skills, connections and tokens)?",
"input.inputMethodsFailed": "Input methods could not be updated",
"input.keyboardLayoutsFailed": "Keyboard layouts could not be updated",
"input.keyboardLayoutRequired": "Select at least one keyboard layout",
"input.keyboardLayoutOverride": "Your personal keyboard layout override takes precedence over this selection",
"input.installEngineToUse": "Install %1 to use %2",
"input.touchpadDisabled": "Touchpad disabled",
"input.touchpadEnabled": "Touchpad enabled",
"input.touchscreenDisabled": "Touchscreen disabled",
Expand Down
11 changes: 8 additions & 3 deletions default/input-methods/typing_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
import configure as setup


def localized(command, *args):
return subprocess.run(command.split() + list(args), text=True, capture_output=True, check=True).stdout.strip()


def keyboard_catalog():
# Read the same choices as the ISO and first-boot form, then convert console
# keymaps through systemd's mapping, just as localectl does during install.
Expand Down Expand Up @@ -113,7 +117,8 @@ def load_engines(names, catalog):
if subprocess.run(["omarchy-pkg-present", package], capture_output=True).returncode]
if absent or any(name not in setup.PRESETS for name in names):
labels = ", ".join(catalog.get(name, name) for name in names)
raise RuntimeError(f"Install {' '.join(absent) or 'its engine'} to use {labels}")
missing = " ".join(absent) or "its engine"
raise RuntimeError(localized("omarchy-i18n input.installEngineToUse", missing, labels))
# Fcitx discovers engines only at startup, so one installed while it was
# running (by an update, say) needs a restart before it can be selected.
setup.run(["omarchy-restart-xcompose"])
Expand Down Expand Up @@ -163,7 +168,7 @@ def seed_language(method):

def keyboard_values(selected):
if not selected:
raise ValueError("Select at least one keyboard layout")
raise ValueError(localized("omarchy-i18n input.keyboardLayoutRequired"))
parts = [value.split(":", 1) for value in selected]
# Preserve the installer's Latin-leading rule for desktop keybindings.
if parts[0][0] in setup.NON_LATIN:
Expand All @@ -190,7 +195,7 @@ def save_keyboard(selected):
expected = [layout + (":" + variant if variant else "")
for layout, variant in zip(layouts.split(","), variants.split(","))]
if keyboard_selection() != expected:
raise RuntimeError("Your personal keyboard layout override takes precedence over this selection")
raise RuntimeError(localized("omarchy-i18n input.keyboardLayoutOverride"))
first_layout = layouts.split(",")[0]
first_variant = variants.split(",")[0]
group_layout = first_layout + ("-" + first_variant if first_variant else "")
Expand Down
5 changes: 3 additions & 2 deletions test/shell.d/typing-setup-checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@ def test_an_engine_installed_after_fcitx_started_loads_on_selection(self):
self.assertEqual(save.call_args.args[3], [["keyboard-us", ""], ["mozc", ""]])

def test_an_uninstalled_engine_names_its_package_without_restarting(self):
absent = subprocess.CompletedProcess([], 1)
with patch.object(typing.setup, "live_group", return_value=("Default", "us", [["keyboard-us", ""]])), patch.object(typing.setup, "available_methods", return_value=[]), patch.object(typing.subprocess, "run", return_value=absent), patch.object(typing.setup, "run") as run, patch.object(typing, "set_inputs") as save:
real_run = subprocess.run
absent = lambda command, *args, **kwargs: subprocess.CompletedProcess(command, 1) if command[0] == "omarchy-pkg-present" else real_run(command, *args, **kwargs)
with patch.object(typing.setup, "live_group", return_value=("Default", "us", [["keyboard-us", ""]])), patch.object(typing.setup, "available_methods", return_value=[]), patch.object(typing.subprocess, "run", side_effect=absent), patch.object(typing.setup, "run") as run, patch.object(typing, "set_inputs") as save:
with self.assertRaisesRegex(RuntimeError, "Install fcitx5-mozc to use Japanese"):
typing.save_inputs(["mozc"])
run.assert_not_called()
Expand Down
Loading