Fork of the classicui addon (Fcitx5 5.1.23) with a Material 3 look, spring based animations and a right click action menu for candidates. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
70 lines
2.5 KiB
Bash
Executable File
70 lines
2.5 KiB
Bash
Executable File
#!/bin/bash
|
|
# Optional. KWin's "Fading Popups" effect fades popup windows in over 150 ms
|
|
# and out over 600 ms, and the Fcitx5 candidate window counts as a popup. This
|
|
# script copies the effect from the system into your home directory and
|
|
# patches the copy so that only the Fcitx5 window ("fcitx fcitx") skips the
|
|
# fade in and uses a short fade out. All other popups are untouched.
|
|
#
|
|
# The effect is KWin's code (GPL-2.0-or-later), so it is generated from the
|
|
# copy installed on your system instead of being shipped in this repository.
|
|
set -euo pipefail
|
|
|
|
fade_out_ms=${FADE_OUT_MS:-90}
|
|
src=
|
|
for dir in /usr/share/kwin-wayland/effects/fadingpopups /usr/share/kwin/effects/fadingpopups; do
|
|
[ -d "$dir" ] && src=$dir && break
|
|
done
|
|
[ -n "$src" ] || { echo "KWin fadingpopups effect not found" >&2; exit 1; }
|
|
|
|
dst=${XDG_DATA_HOME:-$HOME/.local/share}/kwin-wayland/effects/fadingpopups
|
|
rm -rf "$dst"
|
|
mkdir -p "$(dirname "$dst")"
|
|
cp -r "$src" "$dst"
|
|
|
|
python3 - "$dst/contents/code/main.js" "$fade_out_ms" <<'PY'
|
|
import sys
|
|
path, fade_out = sys.argv[1], sys.argv[2]
|
|
s = open(path).read()
|
|
|
|
def rep(old, new):
|
|
global s
|
|
if old not in s:
|
|
sys.exit("effect source changed upstream, cannot patch: " + old[:50])
|
|
s = s.replace(old, new, 1)
|
|
|
|
rep("var fadingPopupsEffect = {", f'''// Added by m3ui: the Fcitx5 candidate window animates itself.
|
|
var inputMethodWindowClass = "fcitx fcitx";
|
|
var inputMethodFadeOutMs = {fade_out};
|
|
|
|
function isInputMethodWindow(window) {{
|
|
return window.windowClass == inputMethodWindowClass;
|
|
}}
|
|
|
|
var fadingPopupsEffect = {{''')
|
|
rep(''' if (!isPopupWindow(window)) {
|
|
return;
|
|
}
|
|
if (!window.visible) {
|
|
return;
|
|
}''', ''' if (!isPopupWindow(window) || isInputMethodWindow(window)) {
|
|
return;
|
|
}
|
|
if (!window.visible) {
|
|
return;
|
|
}''')
|
|
rep(" duration: fadingPopupsEffect.fadeOutDuration,",
|
|
''' duration: isInputMethodWindow(window)
|
|
? animationTime(inputMethodFadeOutMs)
|
|
: fadingPopupsEffect.fadeOutDuration,''')
|
|
open(path, "w").write(s)
|
|
PY
|
|
|
|
if command -v gdbus >/dev/null; then
|
|
gdbus call --session --dest org.kde.KWin --object-path /Effects \
|
|
--method org.kde.kwin.Effects.unloadEffect fadingpopups >/dev/null || true
|
|
gdbus call --session --dest org.kde.KWin --object-path /Effects \
|
|
--method org.kde.kwin.Effects.loadEffect fadingpopups >/dev/null || true
|
|
fi
|
|
echo "Installed to $dst"
|
|
echo "To undo: rm -rf '$dst' and reload the effect."
|