Skip to content

Repair fcitx5 restart loops from user autostarts - #7474

Closed
nsumbadze wants to merge 3 commits into
omacom:quattrofrom
nsumbadze:fix/fcitx5-autostart-loop
Closed

nsumbadze wants to merge 3 commits into
omacom:quattrofrom
nsumbadze:fix/fcitx5-autostart-loop

Conversation

@nsumbadze

Copy link
Copy Markdown

The Quattro handover moved fcitx5 into omarchy-fcitx5.service, but the original migration only
kills the process that is running at update time. A differently named user autostart entry, such
as ~/.config/autostart/fcitx5.desktop, survives and starts again at the next login.

That instance can claim org.fcitx.Fcitx5 before the service does. fcitx5 then exits cleanly, and
Restart=always turns the service into a permanent two-second restart loop.

This follow-up migration finds user desktop entries whose main Exec= directly launches fcitx5
and marks them Hidden=true, preserving the file and its custom fields. In a graphical session it
hands the running instance back to the supervised service through omarchy-restart-xcompose. A
failed handover remains retryable.

This is a new migration rather than a change to the original handover because existing 4.0 users
may already have recorded that migration as complete.

Testing

  • ./test/all - all 182 test files passed

Closes #7461

Copilot AI balanced review requested due to automatic review settings August 19, 2026 10:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@jkubo

jkubo commented Sep 4, 2026

Copy link
Copy Markdown

This says Closes #7461, but it covers one of the two entry points. @vantuan5644 reported on the issue that the same loop happens with no autostart entry at all: the second fcitx5 is D-Bus activated through the fcitx5 package's own org.fcitx.Fcitx5.service, which nothing masks. Marking autostart entries Hidden=true does not change that path.

Details and a unit side option (StartLimitIntervalSec=60, one line) are in my comment on #7461. Suggest either adding that unit change here so the loop stops for both cases, or changing Closes to Refs so the issue stays open for the D-Bus case.

omarchybot and others added 2 commits September 28, 2026 11:40
The handover ran whenever any autostart entry launched fcitx5, including one already marked Hidden=true, so a healthy session had its input method restarted for nothing. A restart drops every X11 client's input context, which can crash Steam later (omacom#9541). Replace fcitx5 only when a process the service does not own is running; a failed earlier handover still leaves that process behind, so the retry still happens.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A handover that killed the competing fcitx5 but then failed to start the service left nothing running outside it, so a rerun found nothing to replace and passed with the service down; restart whenever the service is not active. Search only this user's processes, since another user's fcitx5 is not competing with this service. Read the last line of a desktop entry that has no final newline, which otherwise missed its Exec key or added a second Hidden key beside Hidden=false.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Codex Medium <[email protected]>
@omarchybot omarchybot added verified Omarchy Triage has verified that this issue is ready for final review ready Good to merge labels Sep 28, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed and verified on an Omarchy worker VM, with three fixes pushed to your branch (cd2dd46). It now waits on the maintainer.

Reproduction. On quattro (fa955bf), with ~/.config/autostart/fcitx5.desktop running fcitx5 -d, the autostart instance took org.fcitx.Fcitx5 and omarchy-fcitx5.service went into its 2-second restart loop (6 restarts in 15 s). Running this migration in that session hid the entry and handed fcitx5 back to the service. The service then owned the bus name with NRestarts=0, the generated [email protected] was gone after daemon-reload, and that still held after a reboot. With the entry un-hidden the loop came straight back. On this worker the service usually starts about 12 ms before the autostart entry and wins, so the loop was forced by starting the autostart instance first. That is the order the reporter hit.

Fixed on your branch:

  • migrations/1787085233.sh:64 restarted fcitx5 whenever any matching entry existed, including one already marked Hidden=true. On the worker a healthy session had its fcitx5 replaced for no reason (MainPID 1003 → 2058). That restart drops every X11 client's input context, which is the Steam crash in XCompose migrations restart fcitx5 and can crash running Steam #9541. It now restarts only when the service is not active, or when one of this user's fcitx5 processes is not the service's own. The retry you built in still works: a handover that killed the stray process and then failed to start the service leaves the service inactive, so a re-run restarts it.
  • pgrep is scoped to the current user, so another logged-in user's fcitx5 no longer triggers a restart.
  • migrations/1787085233.sh:20: read skipped a final line with no trailing newline. That missed an Exec=fcitx5 on the last line, and with Hidden=false last it added a second Hidden= key, which GLib reads as not hidden. It now reads that line too.

Each fix has a test, and each test fails with its fix reverted. The full suite passed on the worker: test/cli, and test/shell with 2270 passed and 0 failed.

Second opinion: Codex Medium reviewed it twice. The first round found the three defects above; I hadn't reasoned about the second or third. The second round, on the pushed head, found nothing further.

Left as they are: entries that launch fcitx5 through a wrapper (env … fcitx5, sh -c) are not matched, and entries restricted with OnlyShowIn= are hidden like the others. Neither seemed worth the extra parsing for this repair.

For the maintainer: Closes #7461 fits the case in that issue's title, but the thread has since documented other ways into the same loop that this does not touch: D-Bus activation through the package's org.fcitx.Fcitx5.service, a manual fcitx5 -r -d, and a missing binary (#11694 covers that one). Only a change to the unit's restart policy would stop the loop for all of them. Whether #7461 should close with this, or stay open for that, is your call.

@omarchybot

Copy link
Copy Markdown
Collaborator

Thank you for this. The work is carried forward in #15508, which brings the still-missing parts of Japanese, Chinese and Korean setup together into one change, so I am closing this in its favour.

The restart loop from #7461 is fixed in #15508 a different way: the unit now runs fcitx5 --replace, so an instance started by any user autostart, a Hyprland exec or by hand hands over the bus name and exits, and the unit stops looping. On a worker that took a stray fcitx5 -d from 5 restarts in 12 seconds to none. A one-time migration only catches autostart files that exist at upgrade, which is why this pull request's approach was not used, but it is what pointed at the problem.

This was checked against quattro by Claude, with Codex at medium effort verifying the claims above. If something here is not covered after all, 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 ready Good to merge verified Omarchy Triage has verified that this issue is ready for final review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

omarchy-fcitx5.service restart-loops forever when a user autostart .desktop launches fcitx5 under a different filename

4 participants