Repository navigation
Poll Fcitx only when there is an input method to switch to - #15184
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rming Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rectories Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…failed group count Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The bar's Fcitx reader (
default/input-methods/indicator.py, started unconditionally byshell/Commons/InputMethodState.qml) made three synchronous D-Bus calls every 500 ms on every machine, including machines with only one input method. It now polls only when there is something to switch between, and otherwise waits for events.org.fcitx.Fcitx5bus name gains or loses an owner (a service start or restart);Save:omarchy-input-method, the Typing pickers and fcitx5-configtool all call it.$FCITX_CONFIG_HOME/profile, else$XDG_CONFIG_HOME/fcitx5/profile. That means a service drop-in that moves it is followed.Gio.File.monitor_file(..., WATCH_MOVES)watches it, plus its target when the profile itself is a link into dotfiles (saves replace the target). It sees saves that rename a new file into place, and inotify resolves a linked directory when the watch is added. Known limit: if the dotfiles are relinked while Fcitx runs, the reader picks that up at Fcitx's next start (or the next shell start), and until then a single-method setup can miss an added engine. I tried following every link hop live, but it cost ~110 lines of path walking plus ~300 lines of tests for cases that rarely happen, so I dropped it.Why polling remains for multi-method users
I looked for a change signal first. Fcitx 5.1.23 exposes
InputMethodGroupsChanged()onController1, but an eavesdroppingdbus-monitoron the fcitx5 connection saw no signal at all forSetInputMethodGroupInfo,SetCurrentIM,Toggle,AddInputMethodGroup,SwitchInputMethodGroup,RemoveInputMethodGroup,ReloadConfigorSave. The other frontends (IBus, portal,InputContext1) signal only the client that owns an input context. The SNI addon would signal icon changes, but Omarchy disables it with--disable notificationitemso it doesn't duplicate the tray entry. With several methods, a switch made by a trigger key inside an application can only be seen by reading, so that case keeps the poll it has today.Measurements
Standalone reader, 60 s window, all threads, voluntary + nonvoluntary context switches (the same counter as the battery audit). This machine has one method,
keyboard-us.Fcitx5's own wakeups fall with it, since it no longer answers three calls per tick (27/s down to 15/s here, and the 15/s includes another shell instance still running quattro's reader).
Tests
test/shell.d/input-indicator-test.shruns the reader in a real GLib loop against a real profile file in oneTemporaryDirectory, with Fcitx stubbed. It covers:FCITX_CONFIG_HOME/XDG_CONFIG_HOMEand from the bus owner's own environment, and the watch moves there when the name appears;Every behaviour was mutation-checked: reverting each fix fails the test.
test/shell.d/input-method-test.shpasses.Live, under the desktop lock, on the final code: I replaced the running shell with this branch's (
omarchy-launch-shellwithOMARCHY_PATHset to the worktree) and focused a foot window. I added Hangul throughSetInputMethodGroupInfo+Save: the keyboard widget appeared showingEN.fcitx5-remote -s hangulchanged it to한, andfcitx5-remote -s keyboard-uschanged it back toEN. Removing Hangul and saving hid the widget. The reader showed 0 wakeups in 20 s before and after, and 416 in 20 s with two methods. The profile came back byte-identical, and the ~/omarchy shell and the Starship theme were restored.For a human to check
🤖 Generated with Claude Code