Posts in category “Linux”

Fcitx5 + Rime on a 2015 Chromebook (postmarketOS): GTK_IM_MODULE=fcitx, not fcitx5

I just got Chinese input (wubi + pinyin via Rime) working on my ASUS C100P Flip Chromebook — postmarketOS edge, armv7, 2 GB RAM, MATE on X11. Two things made it real: a minimal package set, and one environment variable half the internet gets wrong.

Install is 10 packages:

doas apk add fcitx5 fcitx5-rime fcitx5-gtk3 fcitx5-gtk4

Resist the "install everything" reflex. On armv7, fcitx5-chinese-addons doesn't exist, fcitx5-configtool needs plasma6 (never built on armhf), and the old full chain dragged in qt6-qtwebengine, which pins icu-libs-76 — on Alpine edge that froze my nodejs at Node 22 (that icu standoff is exactly why I ripped the whole thing out months ago). Rime alone covers wubi and pinyin; my schemas/dictionaries live in my dotfiles repo and get symlinked into ~/.local/share/fcitx5/rime/, so fcitx5 deploys them on first start.

Then ~/.xprofile:

export GTK_IM_MODULE=fcitx      # NOT fcitx5
export QT_IM_MODULE=fcitx       # NOT fcitx5
export XMODIFIERS="@im=fcitx5"  # yes, this one really is fcitx5

The asymmetry is not a typo. Alpine's fcitx5-gtk registers the GTK input module under the id fcitx only — the widely-documented fcitx5 alias never connects. The symptom is maddening: tray icon alive, right-click menu works, even tray "Restart" works — but fcitx5-remote stays 0 (no input context has ever connected) no matter which window has focus, and no keystroke ever reaches the daemon.

Proof in 60 seconds, using zenity as a disposable GTK app and xdotool to tap Shift into it:

export DBUS_SESSION_BUS_ADDRESS="unix:path=$(ls /tmp/dbus-* | head -1)"
GTK_IM_MODULE=fcitx5 zenity --entry & sleep 2   # fcitx5-remote → 0, dead
GTK_IM_MODULE=fcitx  zenity --entry & sleep 2   # fcitx5-remote → 1
xdotool keydown Shift_L; sleep 0.05; xdotool keyup Shift_L   # → 2: rime active

fcitx5-remote states: 0 = no client ever connected, 1 = inactive, 2 = active. A focused GTK window that never lifts you off 0 is an env problem, not a daemon problem — stop restarting fcitx5 and fix the variable.

Two traps if you debug from an ssh/agent shell. First, fcitx5 started there inherits the shell's stale DBUS_SESSION_BUS_ADDRESS and becomes an orphan daemon on a dead bus, invisible to the GUI session — take the real bus from the session process: tr '\0' '\n' < /proc/$(pgrep -n mate-session)/environ | grep ^DBUS_. Second, environment is baked at process birth: mate-terminal windows are all spawned by a factory that inherited the session's env at login, so per-window fixes don't stick — .xprofile plus one logout/login is the only global cure (mate-terminal --disable-factory buys you a single standalone window meanwhile). After that, double-tap Shift toggles Rime and the dotfiles-managed wubi86/pinyin_simp schemas come up on first deploy.

Let xrdp repair stuck keyboard and mouse state on reconnect

An xrdp reconnect can leave a virtual mouse button or key down. A stuck mouse button creates an X11 pointer grab, so every window appears unable to receive clicks even though XFCE and the taskbar are still alive. The old workaround was to click the stuck button once; a reconnect hook can repair both devices automatically without destroying the desktop session.

Keep the session alive in /etc/xrdp/sesman.ini:

KillDisconnected=false
DisconnectedTimeLimit=0
ReconnectScript=reconnectwm.sh

ReconnectScript is the important part. It runs when xrdp-sesman reconnects a client to an existing session. Put the repair command in /etc/xrdp/reconnectwm.sh:

#!/bin/sh

/usr/local/bin/rdp-input-reset >/dev/null 2>&1 || true

The helper only resets a device when X reports a key or button still down:

#!/bin/sh
set -eu

for name in xrdpMouse xrdpKeyboard; do
    id=$(xinput list --id-only "$name" 2>/dev/null || true)
    [ -n "$id" ] || continue

    if xinput query-state "$id" | grep -Eq '(key|button)\[[0-9]+\]=down'; then
        xinput disable "$id"
        xinput enable "$id"
    fi
done

Run the helper manually when the connection has not dropped:

DISPLAY=:10.0 XAUTHORITY="$HOME/.Xauthority" rdp-input-reset

This is safer than restarting xfwm4, the panel, or the whole desktop: it clears the stale XRDP input devices while preserving windows, terminals, and the session. It is not magic—the hook only runs for a reconnect to an existing session. If the connection remains open while input gets stuck, run the helper manually. KillDisconnected=true is a stronger isolation workaround, but it eventually kills the disconnected desktop, so it is the wrong trade-off for a persistent RDP session.

Remote desktop taskbar won't click, but the terminal still types? A mouse button is stuck down

Over xrdp (Remmina client, XFCE session), the taskbar and every window suddenly ignored clicks. The terminal still took keystrokes. Nothing was hung, and memory was fine.

The cause: the RDP link dropped a mouse button release event. When you press a mouse button, X gives the pointer to the window under it until the button comes up. That is an implicit grab. If the release never arrives, that window keeps the pointer forever, and every other client stops getting clicks.

You can confirm it in two steps. First, ask X which buttons it thinks are down:

export DISPLAY=:10.0          # your xrdp display
xinput list                   # find the xrdpMouse id
xinput query-state 6 | grep down
#   button[3]=down             <- right button stuck

Then make Xorg log who holds the grab by sending the XF86LogGrabInfo keysym. Map it to a free keycode for a moment if it isn't bound:

xmodmap -e "keycode 255 = XF86LogGrabInfo"
xdotool key XF86LogGrabInfo   # or an XTest fake key event
xmodmap -e "keycode 255 ="
grep -A6 'currently active device grabs' ~/.xorgxrdp.10.log
#   Active grab ... on device 'Virtual core pointer'
#   client pid 2491417 xfce4-terminal  (implicit)

The fix is to click the stuck button once inside the remote session. In this case that was a single right-click. The real press and release reach xrdpMouse, the button state clears, and the grab goes away.

Faking the release locally with XTestFakeButtonEvent does not work. It comes from the XTEST device, while the stuck state belongs to the xrdpMouse device. If clicking can't fix it, closing the window that holds the grab also releases it.

The trigger is usually pressing a button just as focus leaves the Remmina window, or an RDP reconnect in the middle of a click.

Chromebook on Linux: Search + top row as media keys, without losing F1–F12

On a Chromebook running Linux, the top row sends plain F1–F10, so brightness and volume keys do nothing. Most remap scripts flip it: media keys by default and Search for F-keys. That makes Ctrl+Alt+F1 a four-key chord. Doing it the other way keeps both: F-keys by default, and Search acts like Fn.

Install keyd (it's packaged in Debian 13) and write /etc/keyd/default.conf:

# internal keyboard only (vendor:product of "AT Translated Set 2 keyboard")
[ids]
0001:0001

# Search is leftmeta; holding it turns the top row into Chromebook actions
[meta]
f1 = back
f2 = forward
f3 = refresh
f4 = f11
f6 = brightnessdown
f7 = brightnessup
f8 = mute
f9 = volumedown
f10 = volumeup

Then restart it:

sudo systemctl restart keyd
sudo journalctl -u keyd -b -o cat | grep match

You should see a DEVICE: match 0001:0001:... line. One gotcha: the Debian package starts keyd as soon as it's installed, before your config exists. The running daemon then logs ignoring for every device until you restart it. Debian also ships the binary as keyd.rvaiya, so keyd check isn't on your PATH.

Restricting [ids] to the built-in keyboard leaves an external USB keyboard's real F-keys alone. You can find your IDs with grep -A4 'AT Translated' /proc/bus/input/devices. The mapping above matches the classic Chromebook top row (back, forward, refresh, fullscreen, overview, brightness −/+, mute, volume −/+).

Old Bay Trail laptop dies with the lid closed and leaves no logs? Cap the C-states

My Linux Chromebook (Celeron N2840, Bay Trail) kept "turning itself off" while the lid was closed. When I opened it the screen was black, and only a long press on Power brought it back. I never shut it down, and the lid action was set to "display off" rather than suspend.

The journal confirmed every boot ended without any shutdown sequence:

journalctl --list-boots
sudo journalctl -b -1 -n 30 --no-pager

The previous boots just stopped. earlyoom logs a line every minute, and that line simply ended. Nothing else was there either: no oops, nothing in /var/lib/systemd/pstore/, memory and temperatures fine. A hard freeze that writes nothing, and only while the machine is idle, is the classic Bay Trail deep C-state bug (kernel bugzilla 109051). It still shows up on a 6.12 kernel.

The usual workaround is to keep the CPU out of the deep idle states:

sudo sed -i 's/^GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"$/GRUB_CMDLINE_LINUX_DEFAULT="quiet splash intel_idle.max_cstate=1"/' /etc/default/grub
sudo update-grub

After a reboot, check it took:

cat /sys/module/intel_idle/parameters/max_cstate      # 1
cat /sys/devices/system/cpu/cpu0/cpuidle/state*/name  # only POLL and C1

The cost is a little more idle power, which hardly matters on AC. If it still freezes, add processor.max_cstate=1 as well.

While I was in there, I found that MX Linux had installed broadcom-sta-dkms, and its wl module was loading on a machine with Intel wifi. That tainted the kernel and printed a WARNING at boot. If lspci shows no Broadcom card, blacklist it:

printf 'blacklist wl\n' | sudo tee /etc/modprobe.d/no-wl.conf
sudo update-initramfs -u