From 9d7d23dc06bae24690807dd8da89e5efc0f0c342 Mon Sep 17 00:00:00 2001 From: Botspot <54716352+Botspot@users.noreply.github.com> Date: Sun, 25 Feb 2024 01:11:43 -0600 Subject: [PATCH] WPS Office: fix running window icon on wayland And now delete the wps cloud server program entirely --- apps/WPS Office/install-64 | 53 ++++++++++++++++++++++++++++++++++---- apps/WPS Office/uninstall | 10 +++++++ 2 files changed, 58 insertions(+), 5 deletions(-) diff --git a/apps/WPS Office/install-64 b/apps/WPS Office/install-64 index 88a42907e1..41c7af365b 100755 --- a/apps/WPS Office/install-64 +++ b/apps/WPS Office/install-64 @@ -22,12 +22,55 @@ wget --header="User-Agent: This download is a result of the Pi-Apps store. Pleas #install libwebp6 and libtiff5 to get PDF export working if package_available libwebp6 && package_available libtiff5 ;then - install_packages "$firejail_package" /tmp/wps-office.deb libwebp6 libtiff5 ttf-mscorefonts-installer || exit 1 + install_packages "$firejail_package" /tmp/wps-office.deb libwebp6 libtiff5 ttf-mscorefonts-installer x11-utils wmctrl || exit 1 else - install_packages "$firejail_package" /tmp/wps-office.deb ttf-mscorefonts-installer "http://ftp.debian.org/debian/pool/main/libw/libwebp/libwebp6_0.6.1-2.1+deb11u2_arm64.deb" "http://ftp.debian.org/debian/pool/main/t/tiff/libtiff5_4.2.0-1+deb11u5_arm64.deb" || exit 1 + install_packages "$firejail_package" /tmp/wps-office.deb ttf-mscorefonts-installer x11-utils wmctrl "http://ftp.debian.org/debian/pool/main/libw/libwebp/libwebp6_0.6.1-2.1+deb11u2_arm64.deb" "http://ftp.debian.org/debian/pool/main/t/tiff/libtiff5_4.2.0-1+deb11u5_arm64.deb" || exit 1 fi rm -f /tmp/wps-office.deb -#Prevent application from connecting to the internet -sudo sed -i 's|^Exec=|Exec=firejail --net=none --noblacklist=~/.local/share/Kingsoft --noblacklist=~/.config/Kingsoft |g' /usr/share/applications/wps*.desktop -rm -f ~/Desktop/wps-office-prometheus.desktop +#make icon symlinks that correspond to WM_CLASS so correct icon is set on Wayland (for main wps window only) +while read file ;do + sudo ln -sf "$file" "$(echo "$file" | sed 's+/mimetypes/+/apps/+g ; s+/wps-office2019-kprometheus.png$+/'"wpsoffice.png+g")" +done < <(dpkg -L wps-office | grep -x '/usr/share/icons/hicolor/.*/mimetypes/wps-office2019-kprometheus.png$') + +sudo update-icon-caches /usr/share/icons/* +sudo xdg-icon-resource forceupdate --mode system + +#Prevent application from connecting to the internet - use runner scripts +sudo rm -f /home/*/.local/share/applications/wps*.desktop /home/*/Desktop/wps*.desktop #remove wps-generated .desktop files +sudo rm -f /opt/kingsoft/wps-office/office6/wpscloudsvr #remove cloud and sign-in features - prevent this unnecessary background process + +#remove firejail from .desktop files (backwards compatibility), use /usr/local/bin commands, and fix file opening argument for WPS Writer (it has %U but only %F works) +sudo sed -i 's|firejail --net=none --noblacklist=~/.local/share/Kingsoft --noblacklist=~/.config/Kingsoft ||g ; +s|^Exec=/usr/bin|Exec=/usr/local/bin|g ; s/%U/%F/g' /usr/share/applications/wps*.desktop + +#Make runner scripts in /usr/local/bin to use firejail and to fix window icon on wayland by changing WM_CLASS +make_wps_script() { + command=$1 + old_wm_class=$2 + new_wm_class=$3 + + cat </dev/null +#!/bin/bash + +rm -f ~/Desktop/wps*.desktop ~/.local/share/applications/wps*.desktop + +(for i in {0..20};do + sleep 0.5 + while read id ;do + xprop -f WM_CLASS 8s -set WM_CLASS "$new_wm_class" -id "\$id" 2>/dev/null + done < <(wmctrl -lx | grep -F ' $old_wm_class ' | awk '{print \$1}') +done) & + +firejail --noprofile --net=none --noblacklist=~/.local/share/Kingsoft --noblacklist=~/.config/Kingsoft /usr/bin/$command "\$@" + +rm -f ~/Desktop/wps*.desktop ~/.local/share/applications/wps*.desktop= +EOF + sudo chmod +x /usr/local/bin/$command +} + +make_wps_script wps wps.wps wps-office2019-wpsmain +make_wps_script wpspdf wpspdf.wps wps-office2019-pdfmain +make_wps_script wpp wpp.wpp wps-office2019-wppmain +make_wps_script et et.et wps-office2019-etmain + diff --git a/apps/WPS Office/uninstall b/apps/WPS Office/uninstall index 4edc043140..00fed3fabb 100755 --- a/apps/WPS Office/uninstall +++ b/apps/WPS Office/uninstall @@ -22,6 +22,16 @@ if [ -d /opt/wps-office-chroot ];then sudo rm -rf /opt/wps-office-chroot || true #this may fail if the chroot is already mounted, but it doesn't matter as the folder is basically empty now and a reboot will handle the unmounting +else + #on 64-bit - remove files that were added by the install-64 script + + #remove icon symlinks + sudo rm -f /usr/share/icons/hicolor/*/apps/wpsoffice.png + #remove runner scripts + sudo rm -f /usr/local/bin/wps + sudo rm -f /usr/local/bin/wpspdf + sudo rm -f /usr/local/bin/wpp + sudo rm -f /usr/local/bin/et fi purge_packages || exit 1