Compare commits
10
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a044bec0ab | ||
|
|
0cd685946b | ||
|
|
cf9e8f3625 | ||
|
|
b0af02555e | ||
|
|
8b5ebc57bf | ||
|
|
d579157881 | ||
|
|
3aa498a6d7 | ||
|
|
87c4e2c8b1 | ||
|
|
4eda649324 | ||
|
|
f2bbf0d6c6 |
No files matched your search
@@ -1,17 +1,22 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy:summary=Configure, inspect, or switch input methods
|
||||
# omarchy:args=<status|cycle|configure [--seed|--defaults] [none|mozc|hangul|pinyin|chewing]>
|
||||
# omarchy:args=<status|cycle [back]|configure --seed|--defaults>
|
||||
# omarchy:hidden=true
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
if [[ ${1:-} == "cycle" ]]; then
|
||||
# The shell's reader retains a choice made while nothing has focus. Without
|
||||
# the shell, switch directly.
|
||||
if [[ $(omarchy-shell shell cycleInput 2>/dev/null) != "ok" ]]; then
|
||||
python "$OMARCHY_PATH/default/input-methods/indicator.py" cycle
|
||||
direction=${2:-next}
|
||||
if [[ $direction != "next" && $direction != "back" ]]; then
|
||||
echo "Usage: omarchy-input-method cycle [back]" >&2
|
||||
exit 1
|
||||
fi
|
||||
# The shell's reader retains a choice made while nothing has focus.
|
||||
if [[ $(omarchy-shell shell cycleInput "$direction") != "ok" ]]; then
|
||||
echo "The shell's input reader is not running" >&2
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
python "$OMARCHY_PATH/default/input-methods/configure.py" "$@"
|
||||
/usr/bin/python3 "$OMARCHY_PATH/default/input-methods/configure.py" "$@"
|
||||
fi
|
||||
@@ -616,7 +616,6 @@ keyboard_form() {
|
||||
confirm_reboot && exec systemctl reboot
|
||||
done
|
||||
|
||||
apply_keyboard "$keyboard"
|
||||
omarchy_persist_input_selection
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ fi
|
||||
|
||||
method=${1:-}
|
||||
if [[ -z $method ]]; then
|
||||
python "$OMARCHY_PATH/default/input-methods/typing_setup.py" input
|
||||
/usr/bin/python3 "$OMARCHY_PATH/default/input-methods/typing_setup.py" input
|
||||
exit
|
||||
fi
|
||||
|
||||
@@ -25,5 +25,5 @@ esac
|
||||
|
||||
mapfile -t packages < <(jq -r --arg method "$method" '.[$method].packages[]' "$OMARCHY_PATH/default/input-methods/presets.json")
|
||||
omarchy-pkg-add "${packages[@]}"
|
||||
omarchy-input-method configure "$method"
|
||||
/usr/bin/python3 "$OMARCHY_PATH/default/input-methods/typing_setup.py" add "$method"
|
||||
echo "Input method added. Use Super+I or the Japanese/Korean input key to switch; existing custom Fcitx keys are preserved."
|
||||
@@ -4,4 +4,4 @@
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
python "$OMARCHY_PATH/default/input-methods/typing_setup.py" keyboard
|
||||
/usr/bin/python3 "$OMARCHY_PATH/default/input-methods/typing_setup.py" keyboard
|
||||
@@ -1,5 +1,3 @@
|
||||
local paths = require("default.hypr.paths")
|
||||
|
||||
-- Same terminal tag test as clipboard.lua.
|
||||
local function active_window_is_terminal()
|
||||
local window = hl.get_active_window()
|
||||
@@ -16,54 +14,15 @@ local function active_window_is_terminal()
|
||||
return false
|
||||
end
|
||||
|
||||
-- Read on demand so adding an engine in a live desktop needs no reload.
|
||||
local function has_input_method()
|
||||
local file = io.open(paths.config_home .. "/fcitx5/profile", "r")
|
||||
if not file then return false end
|
||||
local in_item, found = false, false
|
||||
for line in file:lines() do
|
||||
if line:match("^%[") then
|
||||
in_item = line:match("^%[Groups/%d+/Items/%d+%]$") ~= nil
|
||||
elseif in_item then
|
||||
local name = line:match("^Name=(.+)$")
|
||||
if name and not name:match("^keyboard%-") then found = true end
|
||||
end
|
||||
end
|
||||
file:close()
|
||||
return found
|
||||
end
|
||||
|
||||
-- Keep the desktop shortcut independent of Fcitx's custom switching keys.
|
||||
-- Read the live Fcitx group so setup works without a compositor reload.
|
||||
o.bind("SUPER + I", "Switch input language", "omarchy-input-method cycle")
|
||||
|
||||
-- Preserve custom Ctrl + Space triggers. Without a
|
||||
-- [Hotkey/TriggerKeys] list in the config, fcitx5 uses its default, which has
|
||||
-- Ctrl + Space.
|
||||
local function fcitx5_toggles_on_ctrl_space()
|
||||
local file = io.open(paths.config_home .. "/fcitx5/config", "r")
|
||||
if not file then
|
||||
return true
|
||||
end
|
||||
|
||||
local in_triggers, has_triggers, toggles = false, false, false
|
||||
for line in file:lines() do
|
||||
if line:match("^%[") then
|
||||
in_triggers = line == "[Hotkey/TriggerKeys]"
|
||||
has_triggers = has_triggers or in_triggers
|
||||
elseif in_triggers and line:match("^%d+=Control%+space$") then
|
||||
toggles = true
|
||||
end
|
||||
end
|
||||
|
||||
file:close()
|
||||
return toggles or not has_triggers
|
||||
end
|
||||
o.bind("SUPER + SHIFT + I", "Switch input language back", "omarchy-input-method cycle back")
|
||||
|
||||
-- Pass the tmux/Herdr prefix through and return to direct input, so the next
|
||||
-- key reaches the multiplexer instead of the engine's composition.
|
||||
o.bind("CTRL + SPACE", "Direct input for the terminal prefix", function()
|
||||
if active_window_is_terminal() and has_input_method() and not fcitx5_toggles_on_ctrl_space() then
|
||||
if active_window_is_terminal() then
|
||||
-- Wait for the local controller reply before dispatching the next key.
|
||||
o.shell_succeeds("timeout 0.3 fcitx5-remote --check -c")
|
||||
end
|
||||
|
||||
@@ -36,12 +36,17 @@ function keyboard.vconsole()
|
||||
return read_values("/etc/vconsole.conf")
|
||||
end
|
||||
|
||||
-- Choices whose console keymap is plain US but whose desktop layout is not:
|
||||
-- Korean keeps US letters, and Lao is non-Latin, so US still leads.
|
||||
local desktop_overrides = { kr = true, la = true }
|
||||
|
||||
function keyboard.installed()
|
||||
local values = keyboard.vconsole()
|
||||
if read_values("/etc/omarchy/input-method").XKB_LAYOUT == "kr"
|
||||
local override = read_values("/etc/omarchy/input-method").XKB_LAYOUT
|
||||
if desktop_overrides[override]
|
||||
and (values.XKBLAYOUT or "us") == "us"
|
||||
and (values.XKBVARIANT or "") == "" then
|
||||
values.XKBLAYOUT, values.XKBVARIANT = "kr", ""
|
||||
values.XKBLAYOUT, values.XKBVARIANT = override, ""
|
||||
end
|
||||
return values
|
||||
end
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
"""One Fcitx setup path for offline finalization and a running desktop."""
|
||||
"""Fcitx defaults for offline finalization and updates."""
|
||||
|
||||
import argparse
|
||||
from contextlib import contextmanager
|
||||
@@ -72,6 +72,21 @@ def key_list(entries):
|
||||
return {frozenset(value.split("+")) for value in entries.values()}
|
||||
|
||||
|
||||
def without_ctrl_space(text):
|
||||
# Ctrl+Space belongs to tmux and Herdr, and the terminal binding returns to
|
||||
# direct input on it; a Fcitx toggle on the same key would undo that. Without
|
||||
# a TriggerKeys list Fcitx falls back to its default, which has Ctrl+Space.
|
||||
section = re.search(r"(?ms)^\[Hotkey/TriggerKeys\][ \t]*\n(.*?)(?=^\[|\Z)", text)
|
||||
if not section:
|
||||
return text.rstrip() + ("\n\n" if text.strip() else "") + "[Hotkey/TriggerKeys]\n0=Zenkaku_Hankaku\n1=Hangul\n"
|
||||
keys = values(section[1])
|
||||
kept = [keys[key] for key in sorted(keys, key=lambda key: int(key) if key.isdigit() else 0) if keys[key] != "Control+space"]
|
||||
if len(kept) == len(keys):
|
||||
return text
|
||||
body = "".join(f"{index}={key}\n" for index, key in enumerate(kept)) + ("\n" if section[1].endswith("\n\n") else "")
|
||||
return text[:section.start(1)] + body + text[section.end(1):]
|
||||
|
||||
|
||||
def defaults(config_home, fresh=False):
|
||||
changed = False
|
||||
files = ["config", "conf/quickphrase.conf", "conf/wayland.conf", "conf/xcb.conf", "conf/pinyin.conf"]
|
||||
@@ -80,6 +95,8 @@ def defaults(config_home, fresh=False):
|
||||
original = read(target)
|
||||
shipped = read(ROOT / "config/fcitx5" / name)
|
||||
if name == "config" or name == "conf/quickphrase.conf":
|
||||
if name == "config":
|
||||
original = without_ctrl_space(original)
|
||||
existing = sections(original)
|
||||
additions = []
|
||||
for section, entries in sections(shipped).items():
|
||||
@@ -89,7 +106,6 @@ def defaults(config_home, fresh=False):
|
||||
# Existing lists (including explicitly empty lists) are user choices.
|
||||
# A fresh profile has no working IME shortcut to preserve.
|
||||
stock_lists = {
|
||||
"Hotkey/TriggerKeys": {"0": "Control+space", "1": "Zenkaku_Hankaku", "2": "Hangul"},
|
||||
"Hotkey/ActivateKeys": {"0": "Hangul_Hanja"},
|
||||
"Hotkey/DeactivateKeys": {"0": "Hangul_Romaja"},
|
||||
"Hotkey/AltTriggerKeys": {"0": "Shift_L"},
|
||||
@@ -103,7 +119,8 @@ def defaults(config_home, fresh=False):
|
||||
if section not in existing:
|
||||
additions.append(f"[{section}]\n" + "".join(f"{key}={value}\n" for key, value in entries.items()))
|
||||
if additions:
|
||||
changed |= atomic_write(target, original.rstrip() + ("\n\n" if original.strip() else "") + "\n".join(additions))
|
||||
original = original.rstrip() + ("\n\n" if original.strip() else "") + "\n".join(additions)
|
||||
changed |= atomic_write(target, original)
|
||||
elif name == "conf/pinyin.conf":
|
||||
# Suppress the first-use cloud prompt while preserving any explicit
|
||||
# cloud-prediction preference and all other existing engine settings.
|
||||
@@ -131,41 +148,19 @@ def activation_default():
|
||||
|
||||
|
||||
@contextmanager
|
||||
def transaction(config_home, live=False):
|
||||
def transaction(config_home):
|
||||
data_home = Path(os.environ.get("XDG_DATA_HOME") or str(Path.home() / ".local/share"))
|
||||
paths = [config_home / "fcitx5" / name for name in ["profile", "config", "conf/quickphrase.conf", "conf/wayland.conf", "conf/xcb.conf", "conf/pinyin.conf"]]
|
||||
paths += [config_home / "fontconfig/conf.d/50-omarchy-input-method.conf", data_home / "dbus-1/services/org.fcitx.Fcitx5.service"]
|
||||
before = {path.resolve(): path.read_text() if path.exists() else None for path in paths}
|
||||
try:
|
||||
yield
|
||||
except BaseException as setup_error:
|
||||
if live:
|
||||
# Stop before restoring disk: a graceful stop saves the in-memory profile.
|
||||
try:
|
||||
run(["systemctl", "--user", "stop", "omarchy-fcitx5.service"])
|
||||
subprocess.run(["pkill", "-u", str(os.getuid()), "-x", "fcitx5"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
for attempt in range(50):
|
||||
if subprocess.run(["pgrep", "-u", str(os.getuid()), "-x", "fcitx5"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL).returncode != 0:
|
||||
break
|
||||
time.sleep(0.1)
|
||||
else:
|
||||
raise RuntimeError("Fcitx did not stop for rollback; previous settings could not safely be restored")
|
||||
except (OSError, subprocess.CalledProcessError, RuntimeError) as error:
|
||||
raise RuntimeError(f"Could not stop Fcitx for input rollback: {error} (setup failed: {setup_error})") from error
|
||||
except BaseException:
|
||||
for path, original in before.items():
|
||||
if original is None:
|
||||
path.unlink(missing_ok=True)
|
||||
else:
|
||||
atomic_write(path, original)
|
||||
if live:
|
||||
# Restore memory as well as disk; otherwise Fcitx saves the failed change
|
||||
# again on exit. Bus activation caches also need to forget the new entry.
|
||||
reload_bus()
|
||||
try:
|
||||
run(["omarchy-restart-xcompose"])
|
||||
run(CONTROLLER + ["ReloadConfig"])
|
||||
except (OSError, subprocess.CalledProcessError, RuntimeError) as error:
|
||||
print(f"Could not reload restored input settings: {error}", file=sys.stderr)
|
||||
raise
|
||||
|
||||
|
||||
@@ -174,8 +169,8 @@ def selection():
|
||||
preference = values(read(Path(os.environ.get("OMARCHY_INPUT_SELECTION", "/etc/omarchy/input-method"))))
|
||||
layout = vconsole.get("XKBLAYOUT", "us").split(",")[0] or "us"
|
||||
variant = vconsole.get("XKBVARIANT", "").split(",")[0]
|
||||
if preference.get("XKB_LAYOUT") == "kr" and vconsole.get("XKBLAYOUT", "us") == "us" and not variant:
|
||||
layout, variant = "kr", ""
|
||||
if preference.get("XKB_LAYOUT") in ("kr", "la") and vconsole.get("XKBLAYOUT", "us") == "us" and not variant:
|
||||
layout, variant = preference["XKB_LAYOUT"], ""
|
||||
method = preference.get("INPUT_METHOD", "mozc" if layout == "jp" else "none")
|
||||
if method not in PRESETS:
|
||||
raise ValueError(f"Unknown installed input method: {method}")
|
||||
@@ -260,109 +255,59 @@ def wait_ready(method):
|
||||
raise RuntimeError(f"Fcitx did not load the {method} engine after restart")
|
||||
|
||||
|
||||
def live_append(method):
|
||||
group, layout, items = live_group()
|
||||
if any(item[0] == method for item in items):
|
||||
return
|
||||
try:
|
||||
live_set(group, layout, items + [[method, ""]])
|
||||
if not any(item[0] == method for item in live_group()[2]):
|
||||
raise RuntimeError(f"Fcitx did not retain the {method} engine")
|
||||
except BaseException:
|
||||
live_set(group, layout, items)
|
||||
raise
|
||||
|
||||
|
||||
def select_live_method(method, profile):
|
||||
# Clients reconnect asynchronously after restart. SetCurrentIM silently does
|
||||
# nothing without a focused input context, so verify the saved group default.
|
||||
for attempt in range(30):
|
||||
run(["fcitx5-remote", "-s", method])
|
||||
run(["fcitx5-remote", "-c"])
|
||||
run(CONTROLLER + ["Save"])
|
||||
group = run(["fcitx5-remote", "-q"])
|
||||
for section, entries in sections(read(profile)).items():
|
||||
if re.fullmatch(r"Groups/\d+", section) and entries.get("Name") == group and entries.get("DefaultIM") == method:
|
||||
return
|
||||
time.sleep(0.1)
|
||||
print(f"Input method added; select {method} in Fcitx settings to switch to it.", file=sys.stderr)
|
||||
|
||||
|
||||
def configure(args):
|
||||
config_home = Path(os.environ.get("XDG_CONFIG_HOME") or str(Path.home() / ".config"))
|
||||
running = subprocess.run(["pgrep", "-u", str(os.getuid()), "-x", "fcitx5"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL).returncode == 0
|
||||
# Finalization can be retried after login. A live daemon owns its profile.
|
||||
if args.seed and running:
|
||||
return
|
||||
with transaction(config_home, live=running and not args.defaults):
|
||||
with transaction(config_home):
|
||||
configure_inner(args, config_home, running)
|
||||
|
||||
|
||||
def configure_inner(args, config_home, running):
|
||||
if args.seed or args.defaults:
|
||||
method, layout = selection()
|
||||
else:
|
||||
method, layout = args.method or selection()[0], None
|
||||
if args.method:
|
||||
method = args.method
|
||||
method, layout = selection()
|
||||
profile = config_home / "fcitx5/profile"
|
||||
original = read(profile)
|
||||
if args.seed and not stock_profile(original):
|
||||
return
|
||||
if not args.seed and not args.defaults and not running:
|
||||
raise RuntimeError("Log in to an Omarchy desktop before changing input methods")
|
||||
if not args.seed and not args.defaults and method == "none":
|
||||
raise ValueError("Choose an input engine to add")
|
||||
|
||||
if args.seed:
|
||||
if not stock_profile(original):
|
||||
return
|
||||
atomic_write(profile, profile_text(layout, method))
|
||||
defaults(config_home, fresh=True)
|
||||
activation_default()
|
||||
font_default(config_home, method)
|
||||
elif args.defaults:
|
||||
fresh = stock_profile(original)
|
||||
changed = defaults(config_home, fresh=fresh)
|
||||
if activation_default():
|
||||
reload_bus()
|
||||
# Upgrades can run through sudo/SSH without access to the live user's bus.
|
||||
# Never overwrite its profile or restart input in that context.
|
||||
if fresh:
|
||||
if running:
|
||||
try:
|
||||
group, old_layout, items = live_group()
|
||||
if old_layout == "us" and items == [["keyboard-us", ""]]:
|
||||
new_items = [[f"keyboard-{layout}", ""]]
|
||||
if method != "none":
|
||||
if any(item[0] == method for item in available_methods()):
|
||||
new_items.append([method, ""])
|
||||
else:
|
||||
print(f"Finish input setup after login: omarchy setup input {method}", file=sys.stderr)
|
||||
live_set(group, layout, new_items)
|
||||
if live_group()[1:] != (layout, new_items):
|
||||
live_set(group, old_layout, items)
|
||||
raise RuntimeError("Fcitx did not retain the installed keyboard settings")
|
||||
except (OSError, ValueError, KeyError, IndexError, RuntimeError, subprocess.CalledProcessError) as error:
|
||||
print(f"Input profile alignment deferred until login: {error}", file=sys.stderr)
|
||||
else:
|
||||
atomic_write(profile, profile_text(layout, method))
|
||||
if running and changed:
|
||||
try:
|
||||
run(CONTROLLER + ["ReloadConfig"])
|
||||
except (OSError, subprocess.CalledProcessError) as error:
|
||||
print(f"Input defaults reload deferred until login: {error}", file=sys.stderr)
|
||||
else:
|
||||
# New addons are discovered only at startup. Supervision remains with the
|
||||
# existing unit; never spawn a second fcitx instance ourselves.
|
||||
activation_default()
|
||||
defaults(config_home, fresh=stock_profile(original))
|
||||
return
|
||||
|
||||
fresh = stock_profile(original)
|
||||
changed = defaults(config_home, fresh=fresh)
|
||||
if activation_default():
|
||||
reload_bus()
|
||||
run(["omarchy-restart-xcompose"])
|
||||
wait_ready(method)
|
||||
live_append(method)
|
||||
# The selected language becomes the next active engine; leave Latin input
|
||||
# active until the user deliberately switches. Keep all other group items.
|
||||
select_live_method(method, profile)
|
||||
font_default(config_home, method)
|
||||
# Upgrades can run through sudo/SSH without access to the live user's bus.
|
||||
# Never overwrite its profile or restart input in that context.
|
||||
if fresh:
|
||||
if running:
|
||||
try:
|
||||
group, old_layout, items = live_group()
|
||||
if old_layout == "us" and items == [["keyboard-us", ""]]:
|
||||
new_items = [[f"keyboard-{layout}", ""]]
|
||||
if method != "none":
|
||||
if any(item[0] == method for item in available_methods()):
|
||||
new_items.append([method, ""])
|
||||
else:
|
||||
print(f"Finish input setup after login: omarchy setup input {method}", file=sys.stderr)
|
||||
live_set(group, layout, new_items)
|
||||
if live_group()[1:] != (layout, new_items):
|
||||
live_set(group, old_layout, items)
|
||||
raise RuntimeError("Fcitx did not retain the installed keyboard settings")
|
||||
except (OSError, ValueError, KeyError, IndexError, RuntimeError, subprocess.CalledProcessError) as error:
|
||||
print(f"Input profile alignment deferred until login: {error}", file=sys.stderr)
|
||||
else:
|
||||
atomic_write(profile, profile_text(layout, method))
|
||||
if running and changed:
|
||||
try:
|
||||
run(CONTROLLER + ["ReloadConfig"])
|
||||
except (OSError, subprocess.CalledProcessError) as error:
|
||||
print(f"Input defaults reload deferred until login: {error}", file=sys.stderr)
|
||||
|
||||
|
||||
def main():
|
||||
@@ -370,10 +315,9 @@ def main():
|
||||
commands = parser.add_subparsers(dest="command", required=True)
|
||||
commands.add_parser("status")
|
||||
configure_parser = commands.add_parser("configure")
|
||||
mode = configure_parser.add_mutually_exclusive_group()
|
||||
mode = configure_parser.add_mutually_exclusive_group(required=True)
|
||||
mode.add_argument("--seed", action="store_true")
|
||||
mode.add_argument("--defaults", action="store_true")
|
||||
configure_parser.add_argument("method", nargs="?", choices=PRESETS)
|
||||
args = parser.parse_args()
|
||||
if args.command == "status":
|
||||
method, layout = selection()
|
||||
|
||||
@@ -28,14 +28,6 @@ def snapshot(bus):
|
||||
return {"methods": methods, "current": info[0], "name": info[1], "label": info[4], "language": info[5]}
|
||||
|
||||
|
||||
def cycle(bus, state=None):
|
||||
state = state if state is not None else snapshot(bus)
|
||||
methods = state["methods"]
|
||||
if len(methods) > 1 and state["current"] in methods:
|
||||
following = methods[(methods.index(state["current"]) + 1) % len(methods)]
|
||||
call(bus, "SetCurrentIM", GLib.Variant("(s)", (following,)))
|
||||
|
||||
|
||||
def layout_keyboard(keyboards):
|
||||
typed = [keyboard for keyboard in keyboards if not re.match(
|
||||
r"^(hl-virtual-keyboard|power-button|sleep-button|lid-switch|video-bus)", keyboard.get("name", ""))]
|
||||
@@ -51,24 +43,24 @@ def layout_keyboard(keyboards):
|
||||
return keyboard
|
||||
|
||||
|
||||
def layout_switches(keyboards, index=None):
|
||||
def layout_switches(keyboards, index=None, step=1):
|
||||
keyboard = layout_keyboard(keyboards)
|
||||
if keyboard is None:
|
||||
return []
|
||||
layout = keyboard["layout"]
|
||||
following = index if index is not None else (keyboard.get("active_layout_index", 0) + 1) % len(layout.split(","))
|
||||
following = index if index is not None else (keyboard.get("active_layout_index", 0) + step) % len(layout.split(","))
|
||||
return [["hyprctl", "switchxkblayout", item["name"], str(following)]
|
||||
for item in keyboards if item.get("layout") == layout and item.get("name")]
|
||||
|
||||
|
||||
def cycle_choice(state, keyboards):
|
||||
def cycle_choice(state, keyboards, step=1):
|
||||
methods = state.get("methods", [])
|
||||
keyboard = layout_keyboard(keyboards)
|
||||
primary = next((method for method in methods if method.startswith("keyboard-")), None)
|
||||
if keyboard is None or primary is None:
|
||||
current = state.get("current")
|
||||
if len(methods) > 1 and current in methods:
|
||||
return methods[(methods.index(current) + 1) % len(methods)], None
|
||||
return methods[(methods.index(current) + step) % len(methods)], None
|
||||
return None, None
|
||||
# One direct-input method represents all compositor layouts. Composition
|
||||
# engines follow them in the user's configured order.
|
||||
@@ -82,26 +74,7 @@ def cycle_choice(state, keyboards):
|
||||
position = (current, keyboard.get("active_layout_index", 0) if current == primary else None)
|
||||
if position not in choices:
|
||||
return None, None
|
||||
return choices[(choices.index(position) + 1) % len(choices)]
|
||||
|
||||
|
||||
def cycle_input():
|
||||
try:
|
||||
bus = Gio.bus_get_sync(Gio.BusType.SESSION, None)
|
||||
state = snapshot(bus)
|
||||
except GLib.Error:
|
||||
state = {}
|
||||
devices = subprocess.run(["hyprctl", "-j", "devices"], check=True, text=True, capture_output=True)
|
||||
keyboards = json.loads(devices.stdout).get("keyboards", [])
|
||||
if not state.get("methods"):
|
||||
switches = layout_switches(keyboards)
|
||||
else:
|
||||
method, index = cycle_choice(state, keyboards)
|
||||
if method is not None and method != state.get("current"):
|
||||
call(bus, "SetCurrentIM", GLib.Variant("(s)", (method,)))
|
||||
switches = layout_switches(keyboards, index) if index is not None else []
|
||||
for command in switches:
|
||||
subprocess.run(command, check=True, capture_output=True)
|
||||
return choices[(choices.index(position) + step) % len(choices)]
|
||||
|
||||
|
||||
class Indicator:
|
||||
@@ -111,20 +84,20 @@ class Indicator:
|
||||
self.last = ""
|
||||
self.entries = {}
|
||||
|
||||
def select_next(self):
|
||||
def select_next(self, step=1):
|
||||
devices = subprocess.run(["hyprctl", "-j", "devices"], check=True, text=True, capture_output=True)
|
||||
keyboards = json.loads(devices.stdout).get("keyboards", [])
|
||||
try:
|
||||
state = snapshot(self.bus)
|
||||
except GLib.Error:
|
||||
# Without Fcitx, Super+I still cycles the compositor layouts.
|
||||
for command in layout_switches(keyboards):
|
||||
for command in layout_switches(keyboards, step=step):
|
||||
subprocess.run(command, check=True, capture_output=True)
|
||||
return
|
||||
methods = state["methods"]
|
||||
current = self.pending or state["current"] or self.last
|
||||
state["current"] = current if current in methods else next(iter(methods), "")
|
||||
following, index = cycle_choice(state, keyboards)
|
||||
following, index = cycle_choice(state, keyboards, step)
|
||||
if following is None:
|
||||
return
|
||||
self.pending = following
|
||||
@@ -191,9 +164,9 @@ def watch(bus):
|
||||
buffer += data.decode()
|
||||
while "\n" in buffer:
|
||||
line, buffer = buffer.split("\n", 1)
|
||||
if line == "cycle":
|
||||
if line in ("cycle", "cycle back"):
|
||||
try:
|
||||
indicator.select_next()
|
||||
indicator.select_next(-1 if line == "cycle back" else 1)
|
||||
except (GLib.Error, OSError, ValueError, subprocess.CalledProcessError):
|
||||
indicator.pending = ""
|
||||
refresh()
|
||||
@@ -211,9 +184,6 @@ def watch(bus):
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
if sys.argv[1:] == ["cycle"]:
|
||||
cycle_input()
|
||||
else:
|
||||
watch(Gio.bus_get_sync(Gio.BusType.SESSION, None))
|
||||
watch(Gio.bus_get_sync(Gio.BusType.SESSION, None))
|
||||
except (GLib.Error, OSError, ValueError, subprocess.CalledProcessError) as error:
|
||||
raise SystemExit(str(error))
|
||||
@@ -25,17 +25,12 @@ def keyboard_catalog():
|
||||
mappings.setdefault(fields[0], layout + (":" + variant if variant != "-" else ""))
|
||||
# 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)
|
||||
mappings.update({"bg-cp1251": "bg:phonetic", "colemak": "us:colemak", "cz": "cz:qwerty",
|
||||
"kyrgyz": "kg", "de_CH-latin1": "ch", "no-latin1": "no"})
|
||||
catalog = {}
|
||||
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):
|
||||
for choice in choices.splitlines():
|
||||
label, keymap, *input_settings = choice.split("|")
|
||||
layout = input_settings[1] if len(input_settings) > 1 else mappings.get(keymap, keymap)
|
||||
if label == "Lao":
|
||||
layout = "la"
|
||||
# Composition engines belong in Input Methods, not as duplicate US layouts.
|
||||
catalog.setdefault(layout, label)
|
||||
return catalog
|
||||
@@ -61,7 +56,7 @@ def choose(title, catalog, selected, kind, overrides=None):
|
||||
catalog = {**catalog, **{key: catalog.get(key, key) for key in selected}}
|
||||
rows = picker_rows(catalog, selected)
|
||||
args = ["omarchy-menu-select", title] + list(rows.values())
|
||||
on_change = ["python", str(setup.ROOT / "default/input-methods/typing_setup.py"), "apply", kind, json.dumps({"catalog": catalog, "overrides": overrides or {}})]
|
||||
on_change = ["/usr/bin/python3", str(setup.ROOT / "default/input-methods/typing_setup.py"), "apply", kind, json.dumps({"catalog": catalog, "overrides": overrides or {}})]
|
||||
args += ["--", "--multiple", "--width", "620", "--maxheight", "650", "--on-change", json.dumps(on_change), "--change-key", "typing:" + kind]
|
||||
for key in selected:
|
||||
args += ["--selected", rows[key][1:]]
|
||||
@@ -111,12 +106,27 @@ def configure_inputs():
|
||||
choose("Input Methods", catalog, current, "input", dict(items))
|
||||
|
||||
|
||||
def load_engines(names, catalog):
|
||||
packages = sorted({package for name in names for package in setup.PRESETS.get(name, {}).get("packages", [])})
|
||||
absent = [package for package in packages
|
||||
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}")
|
||||
# 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"])
|
||||
for name in names:
|
||||
setup.wait_ready(name)
|
||||
|
||||
|
||||
def save_inputs(selected, overrides=None):
|
||||
group, layout, items = setup.live_group()
|
||||
catalog, available = input_catalog(items)
|
||||
missing = [catalog.get(name, name) for name in selected if name not in available]
|
||||
missing = [name for name in selected if name not in available]
|
||||
if missing:
|
||||
raise RuntimeError("Restart input after updating Omarchy to use: " + ", ".join(missing))
|
||||
load_engines(missing, catalog)
|
||||
group, layout, items = setup.live_group()
|
||||
set_inputs(group, layout, items, input_items(items, selected, overrides))
|
||||
# Only a saved engine claims the CJK font fallback, and a failed font write
|
||||
# returns the group so the menu's restored checks stay true.
|
||||
@@ -130,6 +140,13 @@ def save_inputs(selected, overrides=None):
|
||||
raise
|
||||
|
||||
|
||||
def add_input(method):
|
||||
group, layout, items = setup.live_group()
|
||||
current = [name for name, override in items if not name.startswith("keyboard-")]
|
||||
if method not in current:
|
||||
save_inputs(current + [method])
|
||||
|
||||
|
||||
def keyboard_values(selected):
|
||||
if not selected:
|
||||
raise ValueError("Select at least one keyboard layout")
|
||||
@@ -207,6 +224,12 @@ def apply_selection(kind, context, values):
|
||||
|
||||
|
||||
def main():
|
||||
if sys.argv[1:2] == ["add"] and len(sys.argv) == 3:
|
||||
try:
|
||||
add_input(sys.argv[2])
|
||||
except (OSError, ValueError, RuntimeError, subprocess.CalledProcessError) as error:
|
||||
raise SystemExit(f"Input method could not be added: {error}")
|
||||
return
|
||||
applying = len(sys.argv) == 5 and sys.argv[1] == "apply"
|
||||
kind = sys.argv[2] if applying else sys.argv[1] if len(sys.argv) == 2 else ""
|
||||
if kind not in ("input", "keyboard"):
|
||||
|
||||
@@ -2,21 +2,21 @@
|
||||
|
||||
The install keyboard picker selects a console keymap plus an optional Fcitx engine. `install/provisioning/setup-form.sh` is shared by the ISO configurator and deferred first-boot owner setup. Its rows are `label|console keymap|input method|desktop XKB override`; the last two fields are optional, so ordinary keyboard choices keep their existing meaning.
|
||||
|
||||
The ISO carries the extra fields in `omarchy_install.input_method` and `omarchy_install.input_xkb_layout`. Both installation paths persist them in `/etc/omarchy/input-method` as `INPUT_METHOD` and `XKB_LAYOUT`. This file is parsed as data, never sourced. Korean has a real US console keymap and a `kr` desktop override; Japanese uses `jp106`, or US when the US-keyboard choice is selected. Console and disk-unlock input remain ordinary keymaps.
|
||||
The ISO carries the extra fields in `omarchy_install.input_method` and `omarchy_install.input_xkb_layout`. Both installation paths persist them in `/etc/omarchy/input-method` as `INPUT_METHOD` and `XKB_LAYOUT`. This file is parsed as data, never sourced. Korean and Lao have a real US console keymap and a `kr` or `la` desktop override (Lao is non-Latin, so US still leads on the desktop); Japanese uses `jp106`, or US when the US-keyboard choice is selected. Console and disk-unlock input remain ordinary keymaps.
|
||||
|
||||
`install/user/input-method.sh` calls `omarchy-input-method configure --seed` during user finalization, before graphical login. The standard engines are in the base package set so deferred provisioning and factory resets do not need network access to configure typing. `default/input-methods/presets.json` is the engine catalog used by the post-install selector.
|
||||
|
||||
`default/input-methods/configure.py` owns the shared configuration behavior. Offline seeding replaces only a missing profile or Fcitx's untouched single `keyboard-us` guess. The group layout matches Hyprland's effective leading layout and variant; non-Latin layouts retain the US-leading behavior used for desktop bindings. The selected composition engine is the group's `DefaultIM`, with `ActiveByDefault=False` so initial typing remains Latin. Existing multilingual profiles and explicitly chosen keyboard layouts are preserved.
|
||||
|
||||
`omarchy setup input <engine>` installs the selected engine, restarts the supervised Fcitx unit so it discovers new addons, and appends the engine through `InputMethodGroupInfo`, `SetInputMethodGroupInfo`, and `Save`. It keeps the group name, layout, existing methods, and their layout overrides. There is no parallel unsupervised daemon. A per-user D-Bus activation file delegates `org.fcitx.Fcitx5` to `omarchy-fcitx5.service`; it is loaded before live restart.
|
||||
`omarchy setup input <engine>` installs the selected engine's packages, then appends it through the same path as the Input Methods picker. Selecting an engine whose package is installed but which the running Fcitx has not discovered (one an update installed, say) restarts the supervised Fcitx unit once and waits for it; an engine whose package is missing is refused with the package name. Changes go through `InputMethodGroupInfo`, `SetInputMethodGroupInfo`, and `Save`, keeping the group name, layout, existing methods in their switching order, and their layout overrides. There is no parallel unsupervised daemon. A per-user D-Bus activation file delegates `org.fcitx.Fcitx5` to `omarchy-fcitx5.service`.
|
||||
|
||||
`Setup > Typing > Keyboard Layouts` and `Input Methods` use the native menu's multi-select mode, with current entries checked and changes applied immediately. `default/input-methods/typing_setup.py` uses the installer’s keyboard choices, converted to desktop layouts through systemd’s keymap table, and reads the current input group. Input selection replaces only the non-keyboard group items and retains selected engines' layout overrides; deselection does not uninstall packages. The standard composition engines are already shipped in the base package set. Closing a picker keeps changes already applied. Failed updates leave its checked state unchanged.
|
||||
|
||||
Keyboard selections are persisted as data in `~/.config/omarchy/keyboard-layouts`; `default.hypr.keyboard.selected()` reads them before falling back to installation defaults. Personal Hyprland overrides still take precedence. A save reloads and validates the compositor, aligns the Fcitx group's primary keyboard with the leading layout/variant, and restores the previous configuration and group on failure. Non-Latin selections keep the installer's Latin-leading rule for desktop shortcuts. System console, disk-unlock, and greeter layouts are unchanged.
|
||||
|
||||
Shortcut defaults reserve Ctrl+Space for Tmux/Herdr, Super+Space for the menu, Super+Shift+Space for the bar, and Super+grave for the console. Hyprland owns Super+I to cycle all selected compositor layouts followed by the configured Fcitx input methods, independently of Fcitx switching keys. With keyboard layouts alone, the same shortcut cycles the compositor layouts, keeping matching devices in sync even without the bar widget. The widget is enabled in the default right-hand bar layout and appears only when more than one input method or keyboard layout is configured. Fcitx handles Zenkaku/Hankaku and Hangul; Henkan activates and Muhenkan deactivates. An existing configured list, including an empty list, is preserved. Stock generated lists are repaired only while the user still has the single-keyboard default profile. A terminal Ctrl+Space returns to direct input before the following key, with a 300 ms timeout and no D-Bus activation; a keyboard-only profile skips this step. Wayland and XCB addons do not override the compositor's XKB settings.
|
||||
Shortcut defaults reserve Ctrl+Space for Tmux/Herdr, Super+Space for the menu, Super+Shift+Space for the bar, and Super+grave for the console. Hyprland owns Super+I to cycle all selected compositor layouts followed by the configured Fcitx input methods, independently of Fcitx switching keys. With keyboard layouts alone, the same shortcut cycles the compositor layouts, keeping matching devices in sync even without the bar widget. The widget is enabled in the default right-hand bar layout and appears only when more than one input method or keyboard layout is configured. Fcitx handles Zenkaku/Hankaku and Hangul; Henkan activates and Muhenkan deactivates. Ctrl+Space is never a Fcitx toggle: `configure --defaults` removes it from any TriggerKeys list, keeping the user's other keys, and writes Omarchy's list where none exists, since Fcitx's built-in default includes it. Other existing lists, including empty ones, are preserved, and stock generated lists are repaired only while the user still has the single-keyboard default profile. A terminal Ctrl+Space returns to direct input before the following key, with a 300 ms timeout and no D-Bus activation. Wayland and XCB addons do not override the compositor's XKB settings.
|
||||
|
||||
The migration installs the standard engines and applies conservative defaults. It aligns an untouched Fcitx keyboard profile with the install layout, using the live controller when Fcitx is running. It leaves existing multilingual profiles and working trigger keys alone. Atomic file writes follow configuration symlinks, preserve file modes, and roll back on a failed seed or live setup so a retry can complete. Live rollback stops Fcitx before restoring disk, then reloads activation and restarts the unit. Migration bus errors defer profile alignment to the next login and do not restart input. If a pre-update daemon has not discovered a new engine, the migration aligns only its keyboard and prints the setup command.
|
||||
The migration installs the standard engines and applies conservative defaults. It aligns an untouched Fcitx keyboard profile with the install layout, using the live controller when Fcitx is running. It leaves existing multilingual profiles and working trigger keys alone. Atomic file writes follow configuration symlinks, preserve file modes, and roll back on a failed seed or migration so a retry can complete. Migration bus errors defer profile alignment to the next login and do not restart input. If a pre-update daemon has not discovered a new engine, the migration aligns only its keyboard and prints the setup command.
|
||||
|
||||
Input selection does not change the system locale, repository region, desktop language, or Latin interface font. A new language setup seeds a CJK fallback preference once; additional languages do not overwrite it.
|
||||
|
||||
|
||||
@@ -122,7 +122,7 @@ or `omarchy.power`. There is no `bar` target.
|
||||
| `reloadConfig` | reload shell.json |
|
||||
| `applyTheme <colorsB64> <shellB64>` | push theme colors + shell.toml |
|
||||
| `toggleBarTransparency` | flip the bar background between solid and transparent |
|
||||
| `cycleInput` | switch to the next input method or layout (Super+I); `not running` without the input reader |
|
||||
| `cycleInput <next\|back>` | switch to the next or previous input method or layout (Super+I, Super+Shift+I); `not running` without the input reader |
|
||||
| `setPluginEnabled <id> <"true"\|…>` | flip enabled bit (`ok` / `unknown`) |
|
||||
| `enablePlugin <id> <placementJson>` | enable and place in one mutation |
|
||||
| `putBarWidget <id> <placementJson>` | place a widget only where absent (`omarchy bar put`) |
|
||||
|
||||
@@ -62,7 +62,7 @@ Japanese (US keyboard)|us|mozc
|
||||
Kazakh|kazakh
|
||||
Korean|us|hangul|kr
|
||||
Kyrgyz|kyrgyz
|
||||
Lao|la-latin1
|
||||
Lao|us||la
|
||||
Latvian|lv
|
||||
Lithuanian|lt
|
||||
Macedonian|mk-utf
|
||||
@@ -114,7 +114,7 @@ omarchy_prompt_keyboard() {
|
||||
omarchy_persist_input_selection() {
|
||||
local target_root=${1:-} method=${keyboard_input_method:-none} layout=${keyboard_xkb_layout:-}
|
||||
case "$method" in none | mozc | hangul | pinyin | chewing) ;; *) return 1 ;; esac
|
||||
case "$layout" in "" | kr) ;; *) return 1 ;; esac
|
||||
case "$layout" in "" | kr | la) ;; *) return 1 ;; esac
|
||||
mkdir -p "$target_root/etc/omarchy"
|
||||
printf 'INPUT_METHOD=%s\nXKB_LAYOUT=%s\n' "$method" "$layout" > "$target_root/etc/omarchy/input-method"
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ On Dell XPS laptops with a haptic touchpad, you can also set the click strength
|
||||
|
||||
Select Japanese, Korean, Chinese (Simplified, Pinyin), or Chinese (Traditional, Zhuyin) when the installer asks for your keyboard. Omarchy configures the keyboard and matching input engine automatically, including during offline first-boot setup. Japanese uses Mozc, Korean uses standard two-set Hangul, Simplified Chinese uses Pinyin, and Traditional Chinese uses Chewing's standard Zhuyin arrangement. Japanese (US keyboard) provides Mozc with a US keyboard layout.
|
||||
|
||||
Typing starts in Latin mode. Press `Super + I` to cycle through configured input methods. On Japanese keyboards, 全角/半角 toggles input, 変換 turns it on, and 無変換 turns it off. On a Korean keyboard layout, dedicated 한/영 and 한자 keys switch Hangul and convert to Hanja. `Ctrl + Space` stays available for Tmux and Herdr; CapsLock stays the compose key.
|
||||
Typing starts in Latin mode. Press `Super + I` to cycle through configured input methods, and `Super + Shift + I` to cycle back. On Japanese keyboards, 全角/半角 toggles input, 変換 turns it on, and 無変換 turns it off. On a Korean keyboard layout, dedicated 한/영 and 한자 keys switch Hangul and convert to Hanja. `Ctrl + Space` stays available for Tmux and Herdr; CapsLock stays the compose key.
|
||||
|
||||
The keyboard indicator appears on the right of the bar when you have multiple keyboard layouts or input methods. Click it to switch input languages; Japanese displays あ for hiragana. For Japanese character choices, switch to Japanese, type a word such as `nihongo`, then press Space twice. Press Enter to accept your choice. If you also have multiple keyboard layouts, right-click the indicator to cycle those.
|
||||
|
||||
@@ -69,7 +69,7 @@ Use _Setup > Typing > Keyboard Layouts_ to select layouts such as English and Fr
|
||||
|
||||
Run `omarchy setup keyboard` or `omarchy setup input` to open the same pickers. To append one language from the command line, use `omarchy setup input mozc`, `hangul`, `pinyin`, or `chewing`. Your custom switching keys are preserved. For alternative engine layouts or keys, install `fcitx5-configtool` with `omarchy pkg add fcitx5-configtool` and launch it from a terminal. Selecting an input language does not change the desktop language.
|
||||
|
||||
Use `Super + I` to cycle through input methods or keyboard layouts. The input indicator appears on the right of the bar only when more than one input method or layout is configured. This desktop binding works alongside your existing Fcitx switching keys; you can override it in `~/.config/hypr/bindings.lua`. Tapping Shift alone is not an input switch: Omarchy uses both Shift keys for CapsLock, which changes how input methods see Shift release. Input engines and the CapsLock compose sequences use the [Fcitx5](https://fcitx-im.org/) service already running in every session.
|
||||
Use `Super + I` to cycle through input methods or keyboard layouts, and `Super + Shift + I` to go back the other way, so with three configured you can move between two neighbours. The input indicator appears on the right of the bar only when more than one input method or layout is configured. This desktop binding works alongside your existing Fcitx switching keys; you can override it in `~/.config/hypr/bindings.lua`. Tapping Shift alone is not an input switch: Omarchy uses both Shift keys for CapsLock, which changes how input methods see Shift release. Input engines and the CapsLock compose sequences use the [Fcitx5](https://fcitx-im.org/) service already running in every session.
|
||||
|
||||
### Use ALT as SUPER
|
||||
|
||||
|
||||
@@ -7,16 +7,16 @@ Singleton {
|
||||
id: root
|
||||
property var state: ({})
|
||||
|
||||
function cycle() {
|
||||
function cycle(back) {
|
||||
if (!watcher.running) return false
|
||||
watcher.write("cycle\n")
|
||||
watcher.write(back ? "cycle back\n" : "cycle\n")
|
||||
return true
|
||||
}
|
||||
|
||||
// One reader and pending selection for every monitor's keyboard widget.
|
||||
Process {
|
||||
id: watcher
|
||||
command: ["/usr/bin/python", Quickshell.env("OMARCHY_PATH") + "/default/input-methods/indicator.py"]
|
||||
command: ["/usr/bin/python3", Quickshell.env("OMARCHY_PATH") + "/default/input-methods/indicator.py"]
|
||||
running: true
|
||||
stdinEnabled: true
|
||||
stdout: SplitParser {
|
||||
|
||||
@@ -185,12 +185,6 @@ function snapshotOf(notification, timestamp) {
|
||||
var id = n.id || 0
|
||||
var expireTimeout = Number(n.expireTimeout || 0)
|
||||
if (!isFinite(expireTimeout) || expireTimeout < 0) expireTimeout = 0
|
||||
var actions = []
|
||||
for (var i = 0; n.actions && i < n.actions.length; i++) {
|
||||
var action = n.actions[i]
|
||||
if (action && action.identifier && action.identifier !== "default")
|
||||
actions.push({ identifier: String(action.identifier), text: String(action.text || action.identifier) })
|
||||
}
|
||||
return {
|
||||
id: id,
|
||||
originalId: id,
|
||||
@@ -201,7 +195,6 @@ function snapshotOf(notification, timestamp) {
|
||||
image: n.image || "",
|
||||
glyph: glyphFromHints(n.hints),
|
||||
execArgv: execArgvFromHints(n.hints),
|
||||
actionsJson: JSON.stringify(actions),
|
||||
urgency: n.urgency,
|
||||
expireTimeout: expireTimeout,
|
||||
timestamp: timestamp === undefined ? Date.now() : timestamp
|
||||
@@ -210,7 +203,7 @@ function snapshotOf(notification, timestamp) {
|
||||
|
||||
// Everything the popup card draws, and therefore everything an in-place
|
||||
// update has to write through to the row and its file.
|
||||
var POPUP_ROLES = ["app", "appIcon", "summary", "body", "image", "glyph", "execArgv", "actionsJson", "urgency", "expireTimeout"]
|
||||
var POPUP_ROLES = ["app", "appIcon", "summary", "body", "image", "glyph", "execArgv", "urgency", "expireTimeout"]
|
||||
|
||||
function popupRoles() {
|
||||
return POPUP_ROLES
|
||||
@@ -270,8 +263,6 @@ function historyEntry(value, normalUrgency) {
|
||||
image: e.image || "",
|
||||
glyph: e.glyph || "",
|
||||
execArgv: e.execArgv || "",
|
||||
// Libnotify actions belong to a live sender; never replay stale buttons.
|
||||
actionsJson: "[]",
|
||||
urgency: typeof e.urgency === "number" ? e.urgency : normalUrgency,
|
||||
expireTimeout: 0,
|
||||
timestamp: e.timestamp || 0
|
||||
|
||||
@@ -239,7 +239,7 @@ Item {
|
||||
// about after the popup exists.
|
||||
readonly property var updateSignals: [
|
||||
"summaryChanged", "bodyChanged", "appNameChanged", "appIconChanged",
|
||||
"imageChanged", "urgencyChanged", "expireTimeoutChanged", "hintsChanged", "actionsChanged"
|
||||
"imageChanged", "urgencyChanged", "expireTimeoutChanged", "hintsChanged"
|
||||
]
|
||||
|
||||
// A client that updates a notification through replaces_id does not produce
|
||||
@@ -431,26 +431,10 @@ Item {
|
||||
// libnotify action — they just expect clicking the notification to
|
||||
// focus their window. Fall back to focusing the sending app by class so
|
||||
// that click-to-jump actually works.
|
||||
if (!invoked && entry.actionsJson && entry.actionsJson !== "[]") return
|
||||
if (!invoked) focusApp(entry)
|
||||
dismissPopup(index)
|
||||
}
|
||||
|
||||
function invokePopupAction(index, identifier) {
|
||||
if (index < 0 || index >= popupModel.count) return
|
||||
var entry = popupModel.get(index)
|
||||
var ref = entry && !isRestoredRow(entry) ? liveRefs[entry.originalId] : null
|
||||
if (!ref || !ref.actions) return
|
||||
for (var i = 0; i < ref.actions.length; i++) {
|
||||
var action = ref.actions[i]
|
||||
if (action && action.identifier === identifier) {
|
||||
action.invoke()
|
||||
dismissPopup(index)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Try to focus an existing Hyprland window matching the notification's
|
||||
// sender. The helper handles case-insensitive class matching.
|
||||
function focusApp(entry) {
|
||||
@@ -746,7 +730,6 @@ Item {
|
||||
image: "",
|
||||
glyph: "",
|
||||
execArgv: "",
|
||||
actionsJson: "[]",
|
||||
urgency: NotificationUrgency.Low,
|
||||
expireTimeout: 0,
|
||||
timestamp: Date.now()
|
||||
@@ -1065,7 +1048,6 @@ Item {
|
||||
required property string body
|
||||
required property string image
|
||||
required property string glyph
|
||||
required property string actionsJson
|
||||
required property int urgency
|
||||
required property double expireTimeout
|
||||
required property double timestamp
|
||||
@@ -1117,11 +1099,9 @@ Item {
|
||||
cornerRadius: service.cornerRadius
|
||||
fontFamily: service.shell && service.shell.bar ? service.shell.bar.fontFamily : ""
|
||||
glyph: cardSlot.glyph
|
||||
actions: JSON.parse(cardSlot.actionsJson || "[]")
|
||||
|
||||
onCloseRequested: service.dismissPopup(cardSlot.index)
|
||||
onCardClicked: service.invokePopupDefault(cardSlot.index)
|
||||
onActionClicked: identifier => service.invokePopupAction(cardSlot.index, identifier)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ BorderSurface {
|
||||
property int urgency: 1
|
||||
property double timestamp: 0
|
||||
property int cornerRadius: 0
|
||||
property var actions: []
|
||||
|
||||
// System monospace font injected by the container.
|
||||
property string fontFamily: ""
|
||||
@@ -36,7 +35,6 @@ BorderSurface {
|
||||
|
||||
signal closeRequested()
|
||||
signal cardClicked()
|
||||
signal actionClicked(string identifier)
|
||||
// Prefer per-notification media/avatar data, then fall back to the app icon.
|
||||
// The `check` flag avoids Qt's missing-texture placeholder for unknown names.
|
||||
readonly property string smallIconSource: image.length > 0 ? image : iconSource(appIcon)
|
||||
@@ -196,27 +194,6 @@ BorderSurface {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Flow {
|
||||
Layout.fillWidth: true
|
||||
Layout.leftMargin: Style.space(12)
|
||||
Layout.rightMargin: Style.space(12)
|
||||
Layout.bottomMargin: visible ? Style.space(10) : 0
|
||||
visible: root.actions.length > 0
|
||||
spacing: Style.space(8)
|
||||
|
||||
Repeater {
|
||||
model: root.actions
|
||||
delegate: Button {
|
||||
required property var modelData
|
||||
text: modelData.text
|
||||
bordered: true
|
||||
foreground: Color.notifications.text
|
||||
fontFamily: root.fontFamily
|
||||
onClicked: root.actionClicked(modelData.identifier)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Hover-revealed close. Stacked after mainColumn so its MouseArea sits
|
||||
|
||||
+2
-2
@@ -1781,8 +1781,8 @@ ShellRoot {
|
||||
|
||||
// Super+I goes through the bar's reader, which keeps a choice made before
|
||||
// any text field has focus until one does.
|
||||
function cycleInput(): string {
|
||||
return Commons.InputMethodState.cycle() ? "ok" : "not running"
|
||||
function cycleInput(direction: string): string {
|
||||
return Commons.InputMethodState.cycle(direction === "back") ? "ok" : "not running"
|
||||
}
|
||||
|
||||
function rescanPlugins(): void {
|
||||
|
||||
@@ -107,31 +107,20 @@ assert_fires "the JIS + key zooms the Obsidian Flatpak in with Ctrl + ^" \
|
||||
$'send CTRL asciicircum down\nsend CTRL asciicircum up' "$zoom" "md.obsidian.Obsidian"
|
||||
|
||||
# The prefix bind has to pass Ctrl + Space on, or tmux and Herdr never see it.
|
||||
# Fcitx never toggles on it (configure --defaults removes it from its keys), so
|
||||
# a terminal can always return to direct input first.
|
||||
prefix="CTRL + SPACE"
|
||||
freed=$'[Hotkey/TriggerKeys]\n0=Zenkaku_Hankaku\n\n[Hotkey/ActivateKeys]\n0=Henkan'
|
||||
TEST_FCITX5_CONFIG=$freed assert_fires "the terminal prefix switches to direct input once Ctrl + Space no longer toggles" \
|
||||
$'non_consuming\nexec timeout 0.3 fcitx5-remote --check -c' "$prefix" "com.mitchellh.ghostty" "terminal*"
|
||||
TEST_FCITX5_CONFIG=$freed assert_fires "the prefix leaves input alone outside terminals" \
|
||||
"non_consuming" "$prefix" "chromium" "browser"
|
||||
|
||||
# While fcitx5 still toggles on Ctrl + Space, switching to direct input would
|
||||
# undo the toggle it just made.
|
||||
assert_fires "the prefix leaves input alone without an fcitx5 config" \
|
||||
"non_consuming" "$prefix" "com.mitchellh.ghostty" "terminal*"
|
||||
TEST_FCITX5_CONFIG=$'[Behavior]\nShareInputState=No' assert_fires "the prefix leaves input alone with the default trigger keys" \
|
||||
"non_consuming" "$prefix" "com.mitchellh.ghostty" "terminal*"
|
||||
TEST_FCITX5_CONFIG=$'[Hotkey/TriggerKeys]\n0=Zenkaku_Hankaku\n1=Control+space' assert_fires "the prefix leaves input alone while Ctrl + Space is a trigger key" \
|
||||
"non_consuming" "$prefix" "com.mitchellh.ghostty" "terminal*"
|
||||
|
||||
direct=$'non_consuming\nexec timeout 0.3 fcitx5-remote --check -c'
|
||||
assert_fires "the terminal prefix switches to direct input" "$direct" "$prefix" "com.mitchellh.ghostty" "terminal*"
|
||||
assert_fires "the prefix leaves input alone outside terminals" "non_consuming" "$prefix" "chromium" "browser"
|
||||
for layout in us kr; do
|
||||
TEST_LAYOUT="$layout" TEST_FCITX5_CONFIG=$freed assert_fires "the terminal prefix works with $layout keyboards too" \
|
||||
$'non_consuming\nexec timeout 0.3 fcitx5-remote --check -c' "$prefix" "foot" "terminal"
|
||||
TEST_LAYOUT="$layout" assert_fires "the terminal prefix works with $layout keyboards too" "$direct" "$prefix" "foot" "terminal"
|
||||
done
|
||||
|
||||
TEST_KEYBOARD_ONLY=true TEST_FCITX5_CONFIG=$freed assert_fires "keyboard-only profiles skip the terminal controller call" \
|
||||
"non_consuming" "$prefix" "foot" "terminal"
|
||||
TEST_KEYBOARD_ONLY=true assert_fires "keyboard-only profiles use the same prefix bind" "$direct" "$prefix" "foot" "terminal"
|
||||
|
||||
assert_fires "Super + I cycles configured input independently of custom Fcitx keys" \
|
||||
"exec omarchy-input-method cycle" "SUPER + I" "chromium"
|
||||
assert_fires "Super + Shift + I cycles configured input back" \
|
||||
"exec omarchy-input-method cycle back" "SUPER + SHIFT + I" "chromium"
|
||||
TEST_KEYBOARD_ONLY=true assert_fires "Super + I cycles keyboard layouts without an input engine" \
|
||||
"exec omarchy-input-method cycle" "SUPER + I" "foot" "terminal"
|
||||
@@ -148,6 +148,8 @@ sddm_layouts=$(sed -n '/^local non_latin_layouts =/,+1p' "$sddm_lua" | grep -o '
|
||||
pass "greeter non-latin layout list stays in sync with the initramfs hook"
|
||||
|
||||
TEST_INPUT_PREFERENCE=$'INPUT_METHOD=hangul\n XKB_LAYOUT="kr" # desktop only\n' assert_input "Korean selection overrides its installer US layout" "[kr] [] [$base_options]" $'XKBLAYOUT=us\n'
|
||||
TEST_INPUT_PREFERENCE=$'INPUT_METHOD=none\nXKB_LAYOUT=la\n' assert_input "Lao selection gets Lao behind US on the desktop" "[us,la] [,] [$toggle_options]" $'XKBLAYOUT=us\n'
|
||||
TEST_INPUT_PREFERENCE=$'INPUT_METHOD=none\nXKB_LAYOUT=xx\n' assert_input "an unknown desktop override is ignored" "[us] [] [$base_options]" $'XKBLAYOUT=us\n'
|
||||
TEST_INPUT_PREFERENCE=$'INPUT_METHOD=hangul\nXKB_LAYOUT=kr\n' assert_input "a later US variant overrides the Korean preference" "[us] [intl] [$base_options]" $'XKBLAYOUT=us\nXKBVARIANT=intl\n'
|
||||
TEST_INPUT_PREFERENCE=$'INPUT_METHOD=hangul\nXKB_LAYOUT=kr\n' assert_input "a later layout overrides the Korean preference" "[de] [nodeadkeys] [$base_options]" $'XKBLAYOUT=de\nXKBVARIANT=nodeadkeys\n'
|
||||
|
||||
|
||||
@@ -27,14 +27,7 @@ with patch.object(indicator, "call", side_effect=[
|
||||
print("ok - live state deduplicates modes and reads language independently of the engine label")
|
||||
|
||||
def check_cycle(current, methods, expected):
|
||||
state = {"current": current, "methods": methods}
|
||||
with patch.object(indicator, "snapshot", return_value=state), patch.object(indicator, "call") as call:
|
||||
indicator.cycle(None)
|
||||
if expected is None:
|
||||
call.assert_not_called()
|
||||
else:
|
||||
assert call.call_args.args[1] == "SetCurrentIM"
|
||||
assert call.call_args.args[2].unpack() == (expected,)
|
||||
assert indicator.cycle_choice({"current": current, "methods": methods}, [])[0] == expected
|
||||
|
||||
check_cycle("keyboard-us", ["keyboard-us", "mozc"], "mozc")
|
||||
check_cycle("mozc", ["keyboard-us", "mozc"], "keyboard-us")
|
||||
@@ -77,9 +70,9 @@ with patch.object(indicator, "snapshot", side_effect=lambda bus: dict(live)), pa
|
||||
assert reader.pending == ""
|
||||
print("ok - desktop clicks update the label, cycle pending choices, and apply once a text context exists")
|
||||
|
||||
with patch.object(indicator.Gio, "bus_get_sync", return_value=None), patch.object(indicator, "snapshot", return_value={"methods": ["keyboard-us", "keyboard-fr"], "current": "keyboard-us"}), patch.object(indicator, "call") as call, patch.object(indicator.subprocess, "run", return_value=subprocess.CompletedProcess([], 0, stdout='{"keyboards": []}')) as process:
|
||||
indicator.cycle_input()
|
||||
assert call.call_args.args[2].unpack() == ("keyboard-fr",)
|
||||
with patch.object(indicator, "snapshot", return_value={"methods": ["keyboard-us", "keyboard-fr"], "current": "keyboard-us"}), patch.object(indicator, "call") as call, patch.object(indicator.subprocess, "run", return_value=subprocess.CompletedProcess([], 0, stdout='{"keyboards": []}')) as process:
|
||||
indicator.Indicator(None).select_next()
|
||||
assert call.call_args_list[0].args[2].unpack() == ("keyboard-fr",)
|
||||
assert process.call_count == 1
|
||||
print("ok - the shortcut cycles Fcitx keyboard methods without requiring a bar widget")
|
||||
|
||||
@@ -100,34 +93,29 @@ assert indicator.layout_switches([]) == []
|
||||
print("ok - layout switching synchronizes matching devices, wraps, and preserves device-specific layouts")
|
||||
|
||||
import json
|
||||
import subprocess
|
||||
with patch.object(indicator.Gio, "bus_get_sync", return_value=None), patch.object(indicator, "snapshot", return_value={"methods": ["keyboard-us"], "current": "keyboard-us"}), patch.object(indicator.subprocess, "run", return_value=subprocess.CompletedProcess([], 0, stdout=json.dumps({"keyboards": keyboards}))) as process:
|
||||
indicator.cycle_input()
|
||||
assert process.call_args_list[0].args[0] == ["hyprctl", "-j", "devices"]
|
||||
assert [call.args[0] for call in process.call_args_list[1:]] == indicator.layout_switches(keyboards)
|
||||
def reader_cycle(state, keyboards):
|
||||
with patch.object(indicator, "snapshot", return_value=dict(state)), patch.object(indicator, "call") as call, patch.object(indicator.subprocess, "run", return_value=subprocess.CompletedProcess([], 0, stdout=json.dumps({"keyboards": keyboards}))) as process:
|
||||
indicator.Indicator(None).select_next()
|
||||
return call, [command.args[0] for command in process.call_args_list[1:]]
|
||||
|
||||
call, commands = reader_cycle({"methods": ["keyboard-us"], "current": "keyboard-us"}, keyboards)
|
||||
assert commands == indicator.layout_switches(keyboards)
|
||||
print("ok - keyboard-only input falls back to compositor layouts")
|
||||
with patch.object(indicator.Gio, "bus_get_sync", side_effect=indicator.GLib.Error("no bus")), patch.object(indicator.subprocess, "run", return_value=subprocess.CompletedProcess([], 0, stdout=json.dumps({"keyboards": keyboards}))) as process:
|
||||
indicator.cycle_input()
|
||||
assert [call.args[0] for call in process.call_args_list[1:]] == indicator.layout_switches(keyboards)
|
||||
print("ok - compositor layouts switch even when the Fcitx bus is unavailable")
|
||||
state = {"methods": ["keyboard-us", "mozc", "hangul"], "current": "keyboard-us"}
|
||||
keyboards[1]["active_layout_index"] = 0
|
||||
assert indicator.cycle_choice(state, keyboards) == ("keyboard-us", 1)
|
||||
with patch.object(indicator.Gio, "bus_get_sync", return_value=None), patch.object(indicator, "snapshot", return_value=state), patch.object(indicator, "call") as call, patch.object(indicator.subprocess, "run", return_value=subprocess.CompletedProcess([], 0, stdout=json.dumps({"keyboards": keyboards}))) as process:
|
||||
indicator.cycle_input()
|
||||
call.assert_not_called()
|
||||
assert all(command.args[0][-1] == "1" for command in process.call_args_list[1:])
|
||||
assert len(process.call_args_list) > 1
|
||||
call, commands = reader_cycle(state, keyboards)
|
||||
assert commands and all(command[-1] == "1" for command in commands)
|
||||
assert all(item.args[2].unpack() == ("keyboard-us",) for item in call.call_args_list if item.args[1] == "SetCurrentIM")
|
||||
keyboards[1]["active_layout_index"] = 1
|
||||
assert indicator.cycle_choice(state, keyboards) == ("mozc", None)
|
||||
state["current"] = "mozc"
|
||||
assert indicator.cycle_choice(state, keyboards) == ("hangul", None)
|
||||
state["current"] = "hangul"
|
||||
assert indicator.cycle_choice(state, keyboards) == ("keyboard-us", 0)
|
||||
with patch.object(indicator.Gio, "bus_get_sync", return_value=None), patch.object(indicator, "snapshot", return_value=state), patch.object(indicator, "call") as call, patch.object(indicator.subprocess, "run", return_value=subprocess.CompletedProcess([], 0, stdout=json.dumps({"keyboards": keyboards}))) as process:
|
||||
indicator.cycle_input()
|
||||
assert call.call_args.args[2].unpack() == ("keyboard-us",)
|
||||
assert all(command.args[0][-1] == "0" for command in process.call_args_list[1:])
|
||||
call, commands = reader_cycle(state, keyboards)
|
||||
assert call.call_args_list[0].args[2].unpack() == ("keyboard-us",)
|
||||
assert all(command[-1] == "0" for command in commands)
|
||||
print("ok - layouts and composition engines share one cycle and returning to direct input resets the layout")
|
||||
|
||||
keyboards = [{"name": "physical", "layout": "us,dk", "active_layout_index": 0}]
|
||||
@@ -176,6 +164,16 @@ with patch.object(indicator, "snapshot", side_effect=indicator.GLib.Error("no fc
|
||||
assert keyboards[0]["active_layout_index"] == 1
|
||||
print("ok - the shortcut reader cycles compositor layouts when Fcitx is unavailable")
|
||||
|
||||
keyboards = [{"name": "physical", "layout": "us,dk", "active_layout_index": 0}]
|
||||
state = {"methods": ["keyboard-us", "mozc", "hangul"], "current": "keyboard-us"}
|
||||
assert indicator.cycle_choice(state, keyboards) == ("keyboard-us", 1)
|
||||
assert indicator.cycle_choice(state, keyboards, -1) == ("hangul", None)
|
||||
state["current"] = "mozc"
|
||||
assert indicator.cycle_choice(state, keyboards, -1) == ("keyboard-us", 1)
|
||||
assert indicator.cycle_choice({"methods": ["keyboard-us", "mozc", "hangul"], "current": "keyboard-us"}, [], -1) == ("hangul", None)
|
||||
assert indicator.layout_switches(keyboards, step=-1)[0][-1] == "1"
|
||||
print("ok - cycling back walks the same choices in reverse")
|
||||
|
||||
PY
|
||||
|
||||
stubs=$(mktemp -d)
|
||||
@@ -186,17 +184,21 @@ cat >"$stubs/omarchy-shell" <<'SH'
|
||||
echo "shell $*" >>"$CALLS"
|
||||
echo "$SHELL_REPLY"
|
||||
SH
|
||||
cat >"$stubs/python" <<'SH'
|
||||
#!/bin/bash
|
||||
echo "python ${*##*/}" >>"$CALLS"
|
||||
SH
|
||||
chmod +x "$stubs/omarchy-shell" "$stubs/python"
|
||||
chmod +x "$stubs/omarchy-shell"
|
||||
|
||||
CALLS=$calls SHELL_REPLY=ok PATH="$stubs:$PATH" OMARCHY_PATH="$ROOT" "$ROOT/bin/omarchy-input-method" cycle
|
||||
[[ $(<"$calls") == "shell shell cycleInput" ]] || fail "Super+I goes through the shell's reader" "$(<"$calls")"
|
||||
[[ $(<"$calls") == "shell shell cycleInput next" ]] || fail "Super+I goes through the shell's reader" "$(<"$calls")"
|
||||
pass "Super+I goes through the shell's reader, which retains a choice made without focus"
|
||||
|
||||
if CALLS=$calls SHELL_REPLY="not running" PATH="$stubs:$PATH" OMARCHY_PATH="$ROOT" "$ROOT/bin/omarchy-input-method" cycle 2>/dev/null; then
|
||||
fail "Super+I reports a missing input reader"
|
||||
fi
|
||||
pass "Super+I reports a missing input reader instead of silently doing nothing"
|
||||
|
||||
: >"$calls"
|
||||
CALLS=$calls SHELL_REPLY="" PATH="$stubs:$PATH" OMARCHY_PATH="$ROOT" "$ROOT/bin/omarchy-input-method" cycle
|
||||
[[ $(<"$calls") == $'shell shell cycleInput\npython indicator.py cycle' ]] || fail "Super+I switches directly without the shell" "$(<"$calls")"
|
||||
pass "Super+I switches directly when the shell does not answer"
|
||||
CALLS=$calls SHELL_REPLY=ok PATH="$stubs:$PATH" OMARCHY_PATH="$ROOT" "$ROOT/bin/omarchy-input-method" cycle back
|
||||
[[ $(<"$calls") == "shell shell cycleInput back" ]] || fail "Super+Shift+I cycles back" "$(<"$calls")"
|
||||
if CALLS=$calls PATH="$stubs:$PATH" OMARCHY_PATH="$ROOT" "$ROOT/bin/omarchy-input-method" cycle sideways 2>/dev/null; then
|
||||
fail "an unknown cycle direction is rejected"
|
||||
fi
|
||||
pass "Super+Shift+I cycles back through the shell, and other directions are rejected"
|
||||
@@ -47,7 +47,9 @@ class InputMethodTest(unittest.TestCase):
|
||||
self.addCleanup(self.process.stop)
|
||||
|
||||
def seed(self, method=None):
|
||||
setup.configure(argparse.Namespace(method=method, seed=True, defaults=False))
|
||||
if method:
|
||||
self.preference.write_text(f"INPUT_METHOD={method}\n")
|
||||
setup.configure(argparse.Namespace(seed=True, defaults=False))
|
||||
|
||||
def test_every_installer_engine_is_seeded_and_inactive(self):
|
||||
for method in ("mozc", "hangul", "pinyin", "chewing"):
|
||||
@@ -103,6 +105,14 @@ class InputMethodTest(unittest.TestCase):
|
||||
self.assertEqual(config["Behavior"], {"ActiveByDefault": "True"})
|
||||
self.assertEqual(quickphrase.read_text(), "[TriggerKey]\n\n")
|
||||
|
||||
def test_ctrl_space_is_removed_from_every_trigger_list(self):
|
||||
path = self.config / "fcitx5/config"
|
||||
setup.atomic_write(path, "[Hotkey/TriggerKeys]\n0=Alt+space\n1=Control+space\n2=Hangul\n\n[Behavior]\nActiveByDefault=True\n")
|
||||
setup.defaults(self.config)
|
||||
config = setup.sections(path.read_text())
|
||||
self.assertEqual(config["Hotkey/TriggerKeys"], {"0": "Alt+space", "1": "Hangul"})
|
||||
self.assertEqual(config["Behavior"], {"ActiveByDefault": "True"})
|
||||
|
||||
def test_generated_stock_shortcuts_are_repaired(self):
|
||||
path = self.config / "fcitx5/config"
|
||||
setup.atomic_write(path, "[Hotkey/TriggerKeys]\n0=Control+space\n1=Zenkaku_Hankaku\n2=Hangul\n\n[Hotkey/EnumerateGroupForwardKeys]\n0=Super+space\n")
|
||||
@@ -111,11 +121,16 @@ class InputMethodTest(unittest.TestCase):
|
||||
self.assertEqual(config["Hotkey/EnumerateGroupForwardKeys"], {})
|
||||
self.assertNotIn("Control+space", config["Hotkey/TriggerKeys"].values())
|
||||
|
||||
def test_existing_engine_inherited_hotkeys_are_preserved(self):
|
||||
def test_inherited_hotkeys_keep_fcitx_defaults_except_the_ctrl_space_toggle(self):
|
||||
path = self.config / "fcitx5/config"
|
||||
setup.atomic_write(path, "[Behavior]\nActiveByDefault=True\n")
|
||||
setup.defaults(self.config, fresh=False)
|
||||
self.assertEqual(path.read_text(), "[Behavior]\nActiveByDefault=True\n")
|
||||
self.assertEqual(path.read_text(), "[Behavior]\nActiveByDefault=True\n\n[Hotkey/TriggerKeys]\n0=Zenkaku_Hankaku\n1=Hangul\n")
|
||||
self.assertFalse(setup.defaults(self.config, fresh=False))
|
||||
|
||||
def test_lao_preference_keeps_a_latin_fcitx_keyboard(self):
|
||||
self.preference.write_text("INPUT_METHOD=none\nXKB_LAYOUT=la\n")
|
||||
self.assertEqual(setup.selection(), ("none", "us"))
|
||||
|
||||
def test_korean_preference_yields_to_a_later_keyboard_change(self):
|
||||
self.preference.write_text("INPUT_METHOD=hangul\nXKB_LAYOUT=kr\n")
|
||||
@@ -124,18 +139,6 @@ class InputMethodTest(unittest.TestCase):
|
||||
self.vconsole.write_text(f"XKBLAYOUT={layout}\nXKBVARIANT={variant}\n")
|
||||
self.assertEqual(setup.selection(), ("hangul", expected))
|
||||
|
||||
def test_live_append_keeps_every_method_and_layout(self):
|
||||
info = json.dumps({"data": ["de-nodeadkeys", [["keyboard-de-nodeadkeys", ""], ["mozc", "jp"]]]})
|
||||
updated = json.dumps({"data": ["de-nodeadkeys", [["keyboard-de-nodeadkeys", ""], ["mozc", "jp"], ["hangul", ""]]]})
|
||||
with patch.object(setup, "run", side_effect=["Work", info, "", "", "Work", updated]) as calls:
|
||||
setup.live_append("hangul")
|
||||
self.assertEqual(calls.call_args_list[2].args[0][-10:], ["ssa(ss)", "Work", "de-nodeadkeys", "3", "keyboard-de-nodeadkeys", "", "mozc", "jp", "hangul", ""])
|
||||
self.assertEqual(calls.call_args_list[3].args[0][-1], "Save")
|
||||
info = json.dumps({"data": ["us", [["keyboard-us", ""], ["hangul", ""]]]})
|
||||
with patch.object(setup, "run", side_effect=["Default", info]) as calls:
|
||||
setup.live_append("hangul")
|
||||
self.assertEqual(calls.call_count, 2)
|
||||
|
||||
def test_seed_in_a_live_desktop_is_a_harmless_retry(self):
|
||||
self.seed()
|
||||
profile = self.config / "fcitx5/profile"
|
||||
@@ -152,49 +155,15 @@ class InputMethodTest(unittest.TestCase):
|
||||
self.seed("mozc")
|
||||
self.assertIn("Name=mozc", (self.config / "fcitx5/profile").read_text())
|
||||
|
||||
def test_failed_live_setup_restores_disk_and_restarts_the_daemon(self):
|
||||
self.seed()
|
||||
profile = self.config / "fcitx5/profile"
|
||||
original = profile.read_bytes()
|
||||
events = []
|
||||
def append(method):
|
||||
profile.write_text("failed in-memory state")
|
||||
raise RuntimeError("save failed")
|
||||
def command(args):
|
||||
events.append(args)
|
||||
if args == ["omarchy-restart-xcompose"] and len(events) > 2:
|
||||
self.assertEqual(profile.read_bytes(), original)
|
||||
return ""
|
||||
probes = 0
|
||||
def process(args, **kwargs):
|
||||
nonlocal probes
|
||||
if args[0] == "pgrep":
|
||||
probes += 1
|
||||
return subprocess.CompletedProcess([], 0 if probes == 1 else 1)
|
||||
return subprocess.CompletedProcess([], 0)
|
||||
with patch.object(setup.subprocess, "run", side_effect=process), patch.object(setup, "run", side_effect=command), patch.object(setup, "wait_ready"), patch.object(setup, "live_append", side_effect=append), patch.object(setup.time, "sleep"):
|
||||
with self.assertRaisesRegex(RuntimeError, "save failed"):
|
||||
setup.configure(argparse.Namespace(method="mozc", seed=False, defaults=False))
|
||||
self.assertEqual(profile.read_bytes(), original)
|
||||
self.assertIn(["systemctl", "--user", "stop", "omarchy-fcitx5.service"], events)
|
||||
self.assertEqual(events.count(["omarchy-restart-xcompose"]), 2)
|
||||
|
||||
def test_readiness_checks_the_dbus_array_payload_and_group(self):
|
||||
available = json.dumps({"data": [[["mozc", "Mozc", "", "", "", "ja", False]]]})
|
||||
with patch.object(setup, "run", return_value=available), patch.object(setup, "live_group", return_value=("Default", "us", [["keyboard-us", ""]])):
|
||||
setup.wait_ready("mozc")
|
||||
|
||||
def test_a_silently_dropped_engine_is_rejected_and_group_restored(self):
|
||||
old = ("Default", "us", [["keyboard-us", ""]])
|
||||
with patch.object(setup, "live_group", side_effect=[old, old]), patch.object(setup, "live_set") as setter:
|
||||
with self.assertRaisesRegex(RuntimeError, "retain"):
|
||||
setup.live_append("mozc")
|
||||
self.assertEqual(setter.call_args_list[-1].args, old)
|
||||
|
||||
def test_migration_without_a_bus_keeps_written_activation_and_defaults(self):
|
||||
self.seed()
|
||||
with patch.object(setup, "run", side_effect=subprocess.CalledProcessError(1, "busctl")):
|
||||
setup.configure(argparse.Namespace(method=None, seed=False, defaults=True))
|
||||
setup.configure(argparse.Namespace(seed=False, defaults=True))
|
||||
self.assertTrue((self.home / "data/dbus-1/services/org.fcitx.Fcitx5.service").exists())
|
||||
|
||||
def test_live_migration_without_a_bus_does_not_restart_or_rewrite_profile(self):
|
||||
@@ -202,7 +171,7 @@ class InputMethodTest(unittest.TestCase):
|
||||
profile = self.config / "fcitx5/profile"
|
||||
original = profile.read_bytes()
|
||||
with patch.object(setup.subprocess, "run", return_value=subprocess.CompletedProcess([], 0)), patch.object(setup, "run", side_effect=subprocess.CalledProcessError(1, "busctl")) as calls:
|
||||
setup.configure(argparse.Namespace(method=None, seed=False, defaults=True))
|
||||
setup.configure(argparse.Namespace(seed=False, defaults=True))
|
||||
self.assertEqual(profile.read_bytes(), original)
|
||||
self.assertFalse(any(call.args[0] == ["omarchy-restart-xcompose"] for call in calls.call_args_list))
|
||||
|
||||
@@ -213,40 +182,13 @@ class InputMethodTest(unittest.TestCase):
|
||||
old = ("Default", "us", [["keyboard-us", ""]])
|
||||
new = ("Default", "jp", [["keyboard-jp", ""]])
|
||||
with patch.object(setup.subprocess, "run", return_value=subprocess.CompletedProcess([], 0)), patch.object(setup, "live_group", side_effect=[old, new]), patch.object(setup, "available_methods", return_value=[]), patch.object(setup, "live_set") as setter:
|
||||
setup.configure(argparse.Namespace(method=None, seed=False, defaults=True))
|
||||
setup.configure(argparse.Namespace(seed=False, defaults=True))
|
||||
self.assertEqual(setter.call_args.args, new)
|
||||
|
||||
def test_custom_keyboard_overrides_are_not_stock(self):
|
||||
self.assertFalse(setup.stock_profile(setup.profile_text("de", "none").replace("keyboard-de", "keyboard-us")))
|
||||
self.assertFalse(setup.stock_profile(setup.profile_text("us", "none").replace("Layout=\n", "Layout=ru\n")))
|
||||
|
||||
def test_selected_live_engine_is_verified_after_the_context_reconnects(self):
|
||||
self.seed("mozc")
|
||||
profile = self.config / "fcitx5/profile"
|
||||
saves = 0
|
||||
def command(args):
|
||||
nonlocal saves
|
||||
if args == setup.CONTROLLER + ["Save"]:
|
||||
saves += 1
|
||||
if saves == 2:
|
||||
profile.write_text(profile.read_text().replace("DefaultIM=mozc", "DefaultIM=hangul"))
|
||||
return "Default" if args == ["fcitx5-remote", "-q"] else ""
|
||||
with patch.object(setup, "run", side_effect=command) as commands, patch.object(setup.time, "sleep"):
|
||||
setup.select_live_method("hangul", profile)
|
||||
self.assertEqual(saves, 2)
|
||||
self.assertEqual(sum(call.args[0] == ["fcitx5-remote", "-c"] for call in commands.call_args_list), 2)
|
||||
|
||||
def test_live_setup_does_not_validate_an_unused_install_layout(self):
|
||||
self.seed("mozc")
|
||||
self.vconsole.write_text("XKBLAYOUT=invalid value\n")
|
||||
with patch.object(setup.subprocess, "run", return_value=subprocess.CompletedProcess([], 0)), patch.object(setup, "run", return_value=""), patch.object(setup, "wait_ready"), patch.object(setup, "live_append"), patch.object(setup, "select_live_method"):
|
||||
setup.configure(argparse.Namespace(method="hangul", seed=False, defaults=False))
|
||||
|
||||
def test_live_configuration_requires_a_desktop(self):
|
||||
with self.assertRaisesRegex(RuntimeError, "Log in"):
|
||||
setup.configure(argparse.Namespace(method="mozc", seed=False, defaults=False))
|
||||
self.assertFalse((self.config / "fcitx5/profile").exists())
|
||||
|
||||
def test_atomic_updates_keep_symlinks_and_modes(self):
|
||||
target = self.home / "real-config"
|
||||
target.write_text("before")
|
||||
|
||||
@@ -283,10 +283,6 @@ const notification = {
|
||||
expireTimeout: 1.5
|
||||
}
|
||||
const snapshot = notifications.snapshotOf(notification, 12345)
|
||||
assertDeepEqual(JSON.parse(notifications.snapshotOf({ actions: [
|
||||
{ identifier: 'default', text: 'Open' }, { identifier: 'yes', text: 'Yes' }, { identifier: 'no', text: 'No' }
|
||||
]}).actionsJson), [{ identifier: 'yes', text: 'Yes' }, { identifier: 'no', text: 'No' }], 'explicit choices appear independently of the default card action')
|
||||
assertEqual(notifications.popupEntry({ actionsJson: '[{"identifier":"yes","text":"Yes"}]' }, 1).actionsJson, '[]', 'restored notifications do not replay actions from a dead sender')
|
||||
assertDeepEqual(
|
||||
{
|
||||
id: snapshot.id,
|
||||
|
||||
@@ -70,8 +70,10 @@ SH
|
||||
chmod +x "$stub_bin"/*
|
||||
export PATH="$stub_bin:$PATH"
|
||||
|
||||
sed -n '/^keyboard_form() {/,/^}/p; /^keyboard_xkb_settings() {/,/^}/p; /^apply_keyboard() {/,/^}/p' "$ROOT/bin/omarchy-provision-owner" |
|
||||
sed "s|/etc/|$root/etc/|g" >"$tmp/keyboard.sh"
|
||||
{
|
||||
sed -n '/^keyboard_form() {/,/^}/p; /^keyboard_xkb_settings() {/,/^}/p; /^apply_keyboard() {/,/^}/p' "$ROOT/bin/omarchy-provision-owner"
|
||||
sed -n '/^omarchy_persist_input_selection() {/,/^}/p' "$ROOT/install/provisioning/setup-form.sh"
|
||||
} | sed "s|/etc/|$root/etc/|g" >"$tmp/keyboard.sh"
|
||||
grep -q '^keyboard_form() {' "$tmp/keyboard.sh" && grep -q '^apply_keyboard() {' "$tmp/keyboard.sh" ||
|
||||
fail "omarchy-provision-owner defines the keyboard step"
|
||||
|
||||
@@ -143,6 +145,8 @@ form || fail "a known layout is set" "$(cat "$tmp/screen" "$tmp/log")"
|
||||
grep -qx 'loadkeys dk' "$tmp/calls" && grep -qx 'systemd-firstboot --keymap=dk --force' "$tmp/calls" ||
|
||||
fail "the layout is loaded on the console and persisted" "$(cat "$tmp/calls")"
|
||||
assert_layout dk "a known layout"
|
||||
[[ $(<"$root/etc/omarchy/input-method") == $'INPUT_METHOD=none\nXKB_LAYOUT=' ]] ||
|
||||
fail "a known layout records no input method" "$(cat "$root/etc/omarchy/input-method" 2>&1)"
|
||||
pass "a layout that loads, persists and reads back goes straight to the password form"
|
||||
|
||||
# systemd-firstboot writes only KEYMAP= for a keymap kbd-model-map lacks, as it
|
||||
@@ -191,7 +195,7 @@ model_map=/usr/share/systemd/kbd-model-map
|
||||
if [[ -r $model_map ]]; then
|
||||
source "$ROOT/install/provisioning/setup-form.sh"
|
||||
source "$tmp/keyboard.sh"
|
||||
while IFS='|' read -r label keymap; do
|
||||
while IFS='|' read -r label keymap _; do
|
||||
awk -v k="$keymap" '$1 == k { found = 1 } END { exit !found }' "$model_map" ||
|
||||
{ declare -F keyboard_xkb_settings >/dev/null && keyboard_xkb_settings "$keymap" >/dev/null; } ||
|
||||
fail "the $label layout ($keymap) gets an XKB layout"
|
||||
|
||||
@@ -135,7 +135,7 @@ assert_status 0 "keyboard prompt succeeds"
|
||||
grep -qF -- '--selected English (US)' "$GUM_ARGS" || fail "keyboard prompt preselects English (US)"
|
||||
pass "keyboard prompt maps the chosen label to its keymap"
|
||||
|
||||
for selection in 'Japanese|jp106|mozc|' 'Japanese (US keyboard)|us|mozc|' 'Korean|us|hangul|kr' 'Chinese (Simplified, Pinyin)|us|pinyin|' 'Chinese (Traditional, Zhuyin)|us|chewing|'; do
|
||||
for selection in 'Japanese|jp106|mozc|' 'Japanese (US keyboard)|us|mozc|' 'Korean|us|hangul|kr' 'Lao|us|none|la' 'Chinese (Simplified, Pinyin)|us|pinyin|' 'Chinese (Traditional, Zhuyin)|us|chewing|'; do
|
||||
IFS='|' read -r label keymap method layout <<< "$selection"
|
||||
run_prompt omarchy_prompt_keyboard "0:$label"
|
||||
assert_status 0 "$label can be selected at install"
|
||||
|
||||
@@ -30,7 +30,7 @@ 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.
|
||||
# Converted as the installer does.
|
||||
self.assertEqual(catalog["fr"], "French")
|
||||
self.assertEqual(catalog["bg:phonetic"], "Bulgarian")
|
||||
self.assertEqual(catalog["cz:qwerty"], "Czech")
|
||||
@@ -63,6 +63,31 @@ class TypingSetupTest(unittest.TestCase):
|
||||
typing.save_inputs(["mozc"])
|
||||
self.assertFalse((Path(temporary) / "fontconfig/conf.d/50-omarchy-input-method.conf").exists())
|
||||
|
||||
def test_an_engine_installed_after_fcitx_started_loads_on_selection(self):
|
||||
group = ("Default", "us", [["keyboard-us", ""]])
|
||||
present = subprocess.CompletedProcess([], 0)
|
||||
with patch.object(typing.setup, "live_group", return_value=group), patch.object(typing.setup, "available_methods", return_value=[]), patch.object(typing.subprocess, "run", return_value=present), patch.object(typing.setup, "run") as run, patch.object(typing.setup, "wait_ready") as ready, patch.object(typing, "set_inputs") as save, patch.object(typing.setup, "font_default"):
|
||||
typing.save_inputs(["mozc"])
|
||||
run.assert_called_once_with(["omarchy-restart-xcompose"])
|
||||
ready.assert_called_once_with("mozc")
|
||||
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:
|
||||
with self.assertRaisesRegex(RuntimeError, "Install fcitx5-mozc to use Japanese"):
|
||||
typing.save_inputs(["mozc"])
|
||||
run.assert_not_called()
|
||||
save.assert_not_called()
|
||||
|
||||
def test_command_line_addition_appends_once(self):
|
||||
group = ("Default", "us", [["keyboard-us", ""], ["hangul", ""]])
|
||||
with patch.object(typing.setup, "live_group", return_value=group), patch.object(typing, "save_inputs") as save:
|
||||
typing.add_input("mozc")
|
||||
save.assert_called_once_with(["hangul", "mozc"])
|
||||
typing.add_input("hangul")
|
||||
save.assert_called_once()
|
||||
|
||||
def test_failed_font_write_restores_the_input_group(self):
|
||||
before = [["keyboard-us", ""]]
|
||||
with patch.object(typing.setup, "live_group", return_value=("Default", "us", before)), patch.object(typing.setup, "available_methods", return_value=[["mozc", "Mozc"]]), patch.object(typing, "set_inputs"), patch.object(typing.setup, "font_default", side_effect=OSError("read-only")), patch.object(typing.setup, "live_set") as setter:
|
||||
|
||||
Reference in new issue
Block a user