Alacritty stopped accepting keyboard input on X11 due to a wedged fcitx XIM context
One of my Alacritty windows on Linux Mint (X11/Cinnamon) suddenly stopped accepting keyboard input while holding an active tmux and SSH session. Other Alacritty windows on the same desktop kept working normally.
The terminal itself was not frozen: the tmux status clock kept ticking, the SSH connection stayed alive, and Alacritty’s IPC socket answered immediately. A wedged fcitx XIM context for that single window was swallowing every X11 KeyPress before it reached Alacritty’s keyboard handler. Restarting fcitx (fcitx -r -d) recovered the window in place without closing it, and launching Alacritty with XMODIFIERS=@im=none prevents the freeze from coming back.
Problem 1: One Alacritty window silently drops all keystrokes
Before touching the session, I checked each layer in the input path from another terminal:
- Alacritty process & event loop:
alacritty msg --socket /run/user/1000/Alacritty-:0-<pid>.sock get-configreturned immediately with exit code0, and the tmux clock inside the window continued updating every second. - PTY & tmux:
stty -a -F /dev/pts/<N>showed noixon/ Ctrl-S flow-control freeze;tmux list-clientsandtmux display-messageshowed the pane was not dead, not in copy/Vi mode, and not read-only. - SSH:
ss -tipnshowedRecv-Q=0,Send-Q=0, and active keepalive traffic on the TCP socket.
With tmux and SSH ruled out, the drop had to be inside X11 / winit / IME. Comparing the stuck Alacritty instance against a healthy one exposed the exact point of failure:
- Tracing
recvmsgon the stuck Alacritty’s X11 socket (strace -e trace=recvmsg -x -p <pid>) showed that X11KeyPressevents did arrive at the window, and Alacritty forwarded them tofcitxover_XIM_PROTOCOLClientMessageevents. - However,
fcitxnever sentXIM_FORWARD_EVENTback for that window’s XIM input context. - In
winiton X11 (winit/src/platform_impl/linux/x11/event_processor.rs), key events are passed throughXFilterEvent:
|
|
When fcitx’s XIM state gets wedged for a window, XFilterEvent consumes the KeyPress (True) and fcitx never forwards it back. Setting a breakpoint on Alacritty’s keyboard entry point (alacritty/src/input/keyboard.rs:22) and sending a harmless Shift_L key event confirmed it:
- Working Alacritty window: 2 hits (press + release)
- Stuck Alacritty window: 0 hits
Because each window has its own XIM input context (XIC), one Alacritty window can freeze completely while other Alacritty windows keep working.
Solution 1: Recover the stuck window in place
Reloading fcitx config alone is not enough—fcitx-remote -r keeps the same fcitx process and its wedged XIM context. You need to restart the fcitx daemon so winit tears down the stale XIM connection and creates a fresh one:
|
|
After restarting fcitx:
straceimmediately showedfcitxreturningXIM_FORWARD_EVENT(0x2c) forKeyPressandKeyReleaseon the previously stuck window.- The
Shift_Lprobe hitalacritty/src/input/keyboard.rs:222/2 times, matching the working window. - No terminal windows, tmux sessions, or SSH connections had to be closed.
Solution 2: Prevent the freeze permanently
All running Alacritty instances inherited XMODIFIERS=@im=fcitx from the desktop session. If you don’t need Chinese/IME input inside Alacritty, disable XIM for Alacritty in ~/.local/share/applications/Alacritty.desktop:
|
|
Important: Keep
TryExec=set to the plain binary path (/home/william/.local/bin/alacritty), notenv ....TryExecchecks whether a single executable exists; puttingenv XMODIFIERS=...there marks the.desktopentry invalid.
Validate the file and update the desktop database:
|
|
Any new Alacritty window launched from the menu (and any window spawned from it via Ctrl+Shift+Return) will inherit XMODIFIERS=@im=none and bypass fcitx XIM. Existing Alacritty processes keep their old environment until reopened.
(If you do need IME inside Alacritty, keep fcitx -r -d handy as an in-place recovery command, or consider migrating from fcitx4 to fcitx5.)
Problem 2 (Gotcha): Alacritty disappears from the Linux Mint menu after editing .desktop
If Alacritty.desktop is ever saved in an invalid state even briefly (for example, if TryExec= is accidentally changed while editing Exec=), Cinnamon’s CMenu library can cache a null app_info entry for that file. Even after you fix the file and run touch + update-desktop-database, searching ala in the Mint system menu will stop matching Alacritty.
Fix: Evict Cinnamon’s CMenu cache and reload the menu applet
- Remove and recreate the
.desktopfile so Cinnamon’s file monitor sees a delete + create event:
|
|
- Reload the Cinnamon menu applet so its search index picks up the refreshed entry:
|
|
- Optionally verify directly inside the running Cinnamon session that
AppSystemandmenu@cinnamon.orgboth haveAlacritty:
|
|
Expected output:
|
|
相关内容
- Keep SSH reachable with a closed lid on Linux Mint
- Neovim froze in Insert mode waiting for tmux list-panes
支付宝
微信

william