Files
fcitx5-m3ui/scripts/enable-autostart.sh
T
justmeandClaude Sonnet 5.5 8d14454bb9 Hide forgotten candidates, add autostart script, Chinese README
- Record words picked with "Forget candidate" in a block list and drop them
  from the candidate list before each refresh, so words from read only
  dictionaries stay gone.
- Add scripts/enable-autostart.sh for starting with m3ui at login.
- Make the Chinese README the default, keep the English one as README.en.md.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-19 22:09:23 +08:00

40 lines
1.6 KiB
Bash
Executable File

#!/bin/bash
# Makes Fcitx5 start with m3ui at every login. Writes two user level overrides,
# one for the XDG autostart entry and one for D-Bus activation, nothing outside
# $HOME is touched. If the addon cannot be loaded Fcitx5 falls back to classicui.
#
# Undo: delete the two files printed below and run
# systemctl --user daemon-reload
set -euo pipefail
prefix=${PREFIX:-$HOME/.local/m3ui}
config=${XDG_CONFIG_HOME:-$HOME/.config}
data=${XDG_DATA_HOME:-$HOME/.local/share}
lib=$(find "$prefix" -name libm3ui.so 2>/dev/null | head -1)
[ -n "$lib" ] || { echo "libm3ui.so not found under $prefix, run scripts/install.sh first" >&2; exit 1; }
addondir=$(dirname "$lib")
system_addondir=$(pkg-config --variable=addondir Fcitx5Core 2>/dev/null || true)
system_addondir=${system_addondir:-/usr/lib64/fcitx5}
dirs="$addondir:$system_addondir"
autostart=$config/autostart/org.fcitx.Fcitx5.desktop
service=$data/dbus-1/services/org.fcitx.Fcitx5.service
mkdir -p "$(dirname "$autostart")" "$(dirname "$service")"
# Copy the system entry and change only the Exec line.
sed -E "s#^Exec=/usr/bin/fcitx5\$#Exec=env FCITX_ADDON_DIRS=$dirs /usr/bin/fcitx5 -u m3ui#" \
/etc/xdg/autostart/org.fcitx.Fcitx5.desktop >"$autostart"
grep -q '^Exec=env FCITX_ADDON_DIRS=' "$autostart" ||
{ echo "unexpected system autostart file, nothing changed" >&2; rm -f "$autostart"; exit 1; }
cat >"$service" <<SERVICE
[D-BUS Service]
Name=org.fcitx.Fcitx5
Exec=/usr/bin/env FCITX_ADDON_DIRS=$dirs /usr/bin/fcitx5 -u m3ui
SERVICE
echo "wrote $autostart"
echo "wrote $service"
echo "Apply now: systemctl --user daemon-reload && systemctl --user restart app-org.fcitx.Fcitx5@autostart.service"