Skip to content

Seed fcitx5 DefaultIM from vconsole XKBLAYOUT - #12920

Closed
chessing234 wants to merge 5 commits into
omacom:quattrofrom
chessing234:fix/fcitx5-seed-vconsole-layout
Closed

chessing234 wants to merge 5 commits into
omacom:quattrofrom
chessing234:fix/fcitx5-seed-vconsole-layout

Conversation

@chessing234

@chessing234 chessing234 commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Seed fcitx5 DefaultIM / Default Layout from /etc/vconsole.conf XKBLAYOUT (same source as Hyprland kb_layout), so lock-screen Qt fields stop typing US on non-US installs after wake.
  • Existing installs: migration rewrites only the stock single-IM keyboard-us profile; multi-IM setups are left alone. Fresh installs get the same seed via install/user/fcitx5-layout.sh.
  • Closes Keyboard layout reverts to en after waking from sleep instead of the default layout (e.g. fr) #8060 (Bug A). SDDM greeter layout (Bug B) left alone.

Test plan

  • bash test/shell.d/fcitx5-layout-seed-test.sh
  • Non-US install (XKBLAYOUT=fr): after omarchy-migrate / update, ~/.config/fcitx5/profile has DefaultIM=keyboard-fr; lock screen after sleep types FR
  • Profile with mozc (or other extra IM) is unchanged
  • US console install still keeps stock keyboard-us

@llstrk

llstrk commented Sep 22, 2026

Copy link
Copy Markdown

The active-session migration can undo its own layout change at 4552647b3b51.

Stop fcitx5 before writing its new profile

In migrations/1790096150.sh:9-15, the helper rewrites the profile before omarchy-restart-xcompose stops the running daemon. fcitx5 saves its existing in-memory profile during shutdown, overwriting that change.

With native fcitx5 5.1.22 and a synthetic stock-US profile, the unmodified helper produced this sequence:

Running daemon: US
  -> helper writes FR to disk
  -> daemon receives SIGTERM and exits successfully
  -> disk profile is US again
  -> new daemon's group readback: US

Control: stop daemon -> seed FR -> start daemon
         group readback: FR, retained after shutdown

Impact: an existing non-US installation updated from its desktop session can retain the original wrong layout despite a successful migration. The migration runner then records it as applied, so it does not automatically retry. The stopped-daemon case does not have this ordering problem.

Suggested change: wait for the old fcitx5 process to finish stopping before the final profile write, then start it again when appropriate. Preserve the customized-profile guards and handle stop/write failures explicitly. Include shutdown persistence in the migration regression test; a restart stub that only records a call misses this overwrite.

Verified: targeted helper cases covered French seeding, German nodeadkeys, idempotency, and preservation of US, multi-IM, multi-group and customized profiles.


Review information

Test scope: source review, synthetic configuration cases and native fcitx5 persistence with a private D-Bus session. Migration service/restart routing used stubs; the real systemd service and full installer were not run. Qt lock-screen typing, suspend/resume and non-Latin layout switching were not tested.

Community review: Independent automated community review, unaffiliated with the Omarchy team, intended to help prepare PRs for their review.

Automated AI review: Astra Medium initial inspection and synthesis, independent Opus 5.5 High and Astra Xhigh technical reviews, followed by verification against saved source and runtime evidence.

@chessing234
chessing234 force-pushed the fix/fcitx5-seed-vconsole-layout branch from 4552647 to f28b265 Compare September 26, 2026 00:57
@chessing234

Copy link
Copy Markdown
Contributor Author

stop fcitx5 before rewriting the profile

@llstrk

llstrk commented Sep 27, 2026

Copy link
Copy Markdown

Automated AI review

Community review: Independent automated community review, unaffiliated with the Omarchy team, intended to help prepare PRs for their review.

Follow-up to the earlier review and the author's reply, checked at f28b26521510.

Resolved: the earlier finding "Stop fcitx5 before writing its new profile". bin/omarchy-fcitx5-seed-layout:140-154 now stops fcitx5 before write_profile, and the migration restarts it afterwards when a desktop session is active. Two smaller gaps remain in the new stop path, and the new test does not check the ordering it was added for.

Verified: native fcitx5 5.1.22 on a private D-Bus, stock US profile, XKBLAYOUT=fr, with the unit and process control emulated:

Scenario Previous head 4552647b Current head f28b2652
Unit-managed fcitx5, desktop session active keyboard-us after restart keyboard-fr, kept after a later stop
fcitx5 running outside the unit, desktop session active keyboard-us keyboard-fr
No fcitx5, no session keyboard-fr keyboard-fr
No rewrite needed (already FR, or multi-IM) fcitx5 not stopped fcitx5 not stopped

fcitx5 5.1.23 source keeps the same save-on-exit path (InputMethodManager::save() is unchanged). systemctl --user stop waits for the stop job, so the unit path writes only after fcitx5 has finished saving.

Re-running the installer step leaves fcitx5 stopped

The helper now stops fcitx5, but of its two callers only migrations/1790096150.sh:16-18 starts it again. install/user/fcitx5-layout.sh calls the helper without a restart.

omarchy-provision-user --force   (from a live session, non-US console, stock US profile)
  -> install/user/all.sh -> fcitx5-layout.sh -> helper: stop fcitx5, write FR
  -> no restart: profile is FR, fcitx5 unit inactive

Impact: a manual omarchy-provision-user --force in a running session, when the helper has to rewrite the profile, leaves fcitx5 and its compose sequences off until the next login or omarchy-restart-xcompose. The first-run path is not affected because enable-user-units.sh starts the unit afterwards. At the previous head the same path kept fcitx5 running but lost the seed.

Suggested change: restart what the helper stopped when a graphical session is active, either inside the helper (and drop the migration's separate restart) or in install/user/fcitx5-layout.sh.

Stop failures still report changed

Both stop commands end in || true, and after the ten 0.1 s pgrep checks the helper writes the profile and prints changed without confirming that fcitx5 exited (:143-155). The earlier review suggested handling stop failures explicitly.

Impact: limited to fcitx5 running outside the unit whose shutdown save lands more than about 1 s after SIGTERM, or a stop that fails. The migration is then recorded as applied, and the late save can restore keyboard-us. This was shown only with a synthetic stand-in process, not a real slow fcitx5. The unit path is not affected. Separately, if write_profile fails after the stop, the migration aborts before its restart and fcitx5 stays stopped.

Suggested change: after the wait, exit non-zero if pgrep -x fcitx5 still matches, so the migration stays pending and is retried. Under omarchy-migrate's set -e this also holds back later migrations until the retry.

Optional test improvement: the new case in test/shell.d/fcitx5-layout-seed-test.sh:136-145 checks that stop was called, but not that it happened before the write. A helper mutated to write first and stop afterwards (the original bug) still passes all 13 checks. Making the stop stub copy a stock US profile back over $OMARCHY_FCITX5_PROFILE, as fcitx5's shutdown save does, makes that mutant fail with profile stays fr after stop-then-write while the current head still passes.

Related open PRs:

  • #12896 (1790044019.sh) and #11418 (1789183087.sh) add XKBLAYOUT for installs whose vconsole.conf has KEYMAP but no XKBLAYOUT. This helper treats a missing XKBLAYOUT as US and exits without seeding, and omarchy-migrate still marks 1790096150.sh applied. If this PR's migration runs on an install before either of those lands, the later XKBLAYOUT does not trigger a seed. Shipped together, their lower-numbered migrations run first.
  • #9565 syncs fcitx5 with Hyprland layouts, but only adopts an untouched Default group with us / keyboard-us. It would not adopt or rewrite a group seeded by this PR (source reading, not run).

Documentation: the omarchy-provision-user list in docs/file-layout.md:218-219 ("theme, chromium, git, xcompose, mise, keyring, per-user hardware quirks …") does not mention the new fcitx5 layout seed.


Review information

Test scope: follow-up limited to the stop-before-write change, its callers and the new test, plus source-level checks of related open PRs. fcitx5 5.1.22 ran natively on a private D-Bus in isolation; the systemd user unit, pgrep and pkill were emulated over fixture-owned processes. No real user manager, compositor or graphical-session.target; lock-screen typing was not retested. fcitx5 5.1.23 was checked by source only.

AI process: Opus 5.5 Medium coordination and synthesis, Opus 5.5 Xhigh technical review and final fact check, GPT 6 Sol Xhigh search for related issues, Opus 5.5 Medium editorial check.

Opt out: To stop receiving these reviews, reply to this comment saying so.

@chessing234

Copy link
Copy Markdown
Contributor Author

seed aborts if fcitx5 is still alive after the stop wait, so we do not print changed over a live process.

@llstrk

llstrk commented Sep 28, 2026

Copy link
Copy Markdown

Automated AI review

Community review: Independent automated community review, unaffiliated with the Omarchy team, intended to help prepare PRs for their review.

Follow-up to the previous review and the author's reply, checked at f58750fd1f19.

Resolved: the main part of the earlier finding "Stop failures still report changed". When this user's fcitx5 outlives the wait, bin/omarchy-fcitx5-seed-layout:152-155 now exits 1 without writing or printing changed, so the migration stays pending and is retried. The reply's description is accurate. The earlier stop-before-write fix is unchanged.

Verified: sandboxed runs with real pgrep/pkill against a fixture-owned process named fcitx5 that saves a stock US profile 2 s after SIGTERM:

Slow-exit stand-in Previous head f28b2652 Current head f58750fd
Helper prints changed, writes FR exits 1 after about 1 s, no write
Profile after the late save keyboard-us keyboard-us (unchanged)
omarchy-migrate marks 1790096150.sh applied stays pending, retried next run

The new check also introduces one regression, described below. The earlier review suggested this check without scoping it to the current user.

The new exit also fires for another user's fcitx5

pgrep -x fcitx5 on lines 144, 149 and 152 matches every user's processes. pkill -x fcitx5 cannot signal another user's process, and || true hides that failure.

Second user's desktop session open, this user on a non-US console with a stock US profile:
  helper: stop this user's unit -> pkill cannot stop the other fcitx5
       -> pgrep still matches after about 1 s -> exit 1, profile not written
  migration: `changed=$(...)` fails -> omarchy-migrate exits, marker not written
             -> later migrations do not run; this user's fcitx5 stays stopped
  installer step: omarchy-provision-user (set -euo pipefail) exits at fcitx5-layout.sh,
                  before mise-work.sh

At f28b2652 the same case completed: the profile was written, and the migration was recorded and restarted fcitx5 in a desktop session. That result was correct, because the other user's fcitx5 saves its profile under that user's home.

Impact: limited to multi-user machines where another user's graphical session is open while this user runs migrations (omarchy update or omarchy-migrate) or omarchy-provision-user. There it fails on every retry. Under omarchy update, the migration failure triggers the update's error banner and stops the steps that follow it. In the installer step, later steps (mise, keyring, finalize marker) are skipped. Migrations are documented as running once for every user on the machine (agents/skills/migrations.md).

Suggested change: scope all three checks and the kill to the current user: pgrep -u "$UID" -x fcitx5 and pkill -u "$UID" -x fcitx5.

This was shown with a stand-in that ignores SIGTERM, in the role of a process pkill cannot stop. It was not run with a second real user; the permission failure comes from procps source and kill(2) semantics.

Paths that stop fcitx5 without starting it again

The helper stops fcitx5, but only the migration's success path starts it again. Three paths leave it stopped until the next login or omarchy-restart-xcompose:

  • the installer step install/user/fcitx5-layout.sh, unchanged since the previous review (omarchy-provision-user --force in a live session: profile FR, unit inactive, no restart);
  • a failed write_profile after the stop, also unchanged;
  • the new exit 1: the migration aborts at line 11, before its restart (the unit stub stayed inactive, with 0 restart calls).

On these paths nothing starts fcitx5 again before the next login, despite the comment at lines 140-142.

Impact: fcitx5 input methods and compose sequences stay off until the next login or a manual restart.

Suggested change: have the helper start fcitx5 again on every exit once it has stopped or signalled it, when a graphical session is active (for example with an EXIT trap), and drop the migration's separate restart. This covers all three paths. It has not been tested.

Optional test improvement: no test case exercises the new branch, because every case sets the pgrep stub to report "not running". With lines 152-155 deleted, all 13 checks still pass. A case whose stub pgrep keeps matching, expecting a non-zero exit, no changed and an unchanged profile, passes at f58750fd and fails at f28b2652 with rc=0 out=changed. The earlier suggestion to make the stop stub restore a stock US profile, which checks stop-before-write order, still applies.

Still applies: the docs/file-layout.md:218-219 list still omits the fcitx5 layout seed. #12896, #11418 and #9565 are still open, and the earlier related-PR note is unchanged.


Review information

Test scope: follow-up limited to the new commit, its callers and the earlier findings. Sandboxed runs used real procps against fixture-owned stand-ins named fcitx5: one that saves 2 s after SIGTERM, one after 0.2 s, and one that ignores SIGTERM. The systemd user unit, omarchy-restart-xcompose and the session were stubbed. A second user was emulated, not run under a separate UID. Native fcitx5 was not re-run because the stop-then-write order is unchanged. The suggested code changes were not tested.

AI process: Opus 5.5 Medium coordination and synthesis, Opus 5.5 Xhigh technical review and final fact check, GPT 6 Sol Xhigh search for related issues, Opus 5.5 Medium editorial check.

Opt out: To stop receiving these reviews, reply to this comment saying so.

@greptile-apps

greptile-apps Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium risk] Adds keyboard layout seeding for the input method system.

The PR appears safe to merge; no new actionable issue was identified.

Summary

The PR seeds fcitx5’s default keyboard layout from vconsole on fresh installs and migrates stock single-IM profiles on existing installs. Since the previous review, it aligns non-Latin layouts with Hyprland, preserves custom item layouts, avoids starting an intentionally stopped service, and replaces profile writes atomically.

Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Read vconsole layout] --> B{Leading layout is non-Latin?}
  B -- Yes --> C[Use Hyprland's US-first default]
  B -- No --> D[Choose keyboard layout and variant]
  C --> E{Seed needed and profile eligible?}
  D --> E
  E -- No --> F[Leave profile unchanged]
  E -- Yes --> G[Stop running fcitx5]
  G --> H[Write temporary profile and replace]
  H --> I[Restore previously running service in graphical session]
Loading

Reviews (2) · Last reviewed commit: "Preserve custom input profiles and stopp..."

Comment thread bin/omarchy-fcitx5-seed-layout Resolved
Comment thread bin/omarchy-fcitx5-seed-layout Resolved
Comment thread bin/omarchy-fcitx5-seed-layout Resolved
Comment thread bin/omarchy-fcitx5-seed-layout Resolved
@chessing234

Copy link
Copy Markdown
Contributor Author

fixed in cc07f76: all process checks and signals use the current uid, and the helper restores the session service on exit, including failed stops and writes. 17 fixture checks pass with regression controls for user scoping, stop-before-write ordering and cleanup; a real multi-user desktop and lock-screen run remains unverified.

@greptile-apps

greptile-apps Bot commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

Want your agent to iterate on Greptile's feedback? Try greploops.

@jandrusk

jandrusk commented Oct 8, 2026

Copy link
Copy Markdown

Heads-up for the maintainer: #14433 ("Unify input methods with installer keyboard selection") is now open and reworks fcitx5 setup around the installer's keyboard choice, with its own migration that runs omarchy-input-method configure --defaults. It likely covers or conflicts with this seed. It's worth checking whether #8060's lock-screen case is handled there before this lands separately. #13327 and #13552 touch the same area too.

@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed at 033894fb. The fix this pull request makes has since landed on quattro through #14433 (merge 0b9dace0), which lists this pull request among the input work it consolidates. It also now conflicts with quattro in install/user/all.sh.

What quattro already does, read from source:

  • default/input-methods/configure.py:166-181 reads the first XKBLAYOUT and XKBVARIANT from /etc/vconsole.conf, maps non-Latin layouts to us as Hyprland does, and profile_text (:197-202) writes Default Layout=<layout> and DefaultIM=keyboard-<layout>.
  • Fresh installs: install/user/input-method.sh runs omarchy-input-method configure --seed, which only rewrites a missing, empty or stock single keyboard-us profile (:184-194, :271-278).
  • Existing installs: migrations/1791367434.sh runs configure --defaults. If fcitx5 is stopped, it writes the profile. If fcitx5 is running, it changes the live group over D-Bus and calls Save (:284-302), so the daemon's save-on-exit cannot overwrite the change.

That covers the cause of #8060 Bug A that this pull request targets. Landing both would also do harm. Its migration (1790096150) runs before quattro's (1791367434). On a Japanese install, it would write a keyboard-jp profile that quattro's stock-profile check then refuses, so the Mozc engine the installer selected would never be added. The few cases where the two differ are an explicitly empty Default Layout=, stopping the daemon when there is no usable session bus, and skipping symlinked profiles. None of them is a demonstrated defect on quattro.

Nothing was run on a worker, because the code it would verify is not what quattro ships. This is a source review. Codex Medium was the second opinion and reached the same conclusion on its own reading; independence between the two reviews is not guaranteed. It also found the Japanese ordering problem above, which I checked against the source. Nothing was pushed.

This now waits on the maintainer, with the recommendation that it be closed as superseded by #14433. If a non-US install on current quattro still types US on the lock screen after wake, that belongs on #8060 as a report against the new code.

@omarchybot

Copy link
Copy Markdown
Collaborator

Thank you for this. What it does is now on quattro, so I am closing it.

On quattro, default/input-methods/configure.py writes DefaultIM and the group's default layout from the installed keyboard choice for a missing or untouched stock profile, at install (--seed) and on migration (--defaults); a profile someone has already changed is left alone.

This was checked against quattro by Claude, with Codex at medium effort verifying the claims above. If something here is still missing, say so and this can be reopened.

@omarchybot omarchybot closed this Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Keyboard layout reverts to en after waking from sleep instead of the default layout (e.g. fr)

4 participants