The plugin runs inside the input method and sees everything that is typed, so what it is built from matters. build.sh used to download a tag archive and a yoga archive without checking them. It now fetches both by commit hash and verifies the hash afterwards: a tag can be moved and an archive swapped, a commit hash cannot be faked. A version without a pinned commit is refused unless FCITX_COMMIT is given. Archive checksums were not used on purpose, GitHub does not keep the bytes of generated archives stable. enable-autostart.sh writes paths into an Exec line and a service file and now refuses paths that would need quoting there. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
45 lines
1.9 KiB
Bash
Executable File
45 lines
1.9 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"
|
|
# The paths are written into an Exec line and a service file, refuse anything
|
|
# that would need quoting there instead of producing a broken or surprising line.
|
|
case $dirs in
|
|
*[[:space:]\"\'\\\$\`%]*) echo "unsupported characters in $dirs" >&2; exit 1 ;;
|
|
esac
|
|
|
|
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"
|