if grep -q "Exec=.*$PARAM""$file"; then return 0 fi
local exec_line=$(grep -m1 '^Exec='"$file")
if [[ "$exec_line" =~ [[:space:]] ]]; then sudo sed -i "0,/^Exec=/s|\(Exec=[^[:space:]]*[[:space:]]\)|\1$PARAM |""$file" else sudo sed -i "0,/^Exec=/s|^Exec=.*|& $PARAM|""$file" fi }
# change to your package list path for app in $(cat /home/Kita/.local/bin/ap.lst); do desktop_file="/usr/share/applications/$app.desktop" if [[ -f "$desktop_file" ]]; then modify_desktop "$desktop_file" fi done
add package list such as
1 2 3
cursor-cursor qq cherry-studio
add pacman hook to /etc/pacman.d/hooks/whateveryoucall.hook
[Action] Description = Adding --enable-wyaland-ime to .desktop files When = PostTransaction Exec = /home/Kita/.local/bin/ap #change to your script path
after all package upgrade, this script will run and add
--enable-wayland-ime to the Exec line of the specified
.desktop files.