Skip to content

Commit 9d7d23d

Browse files
committed
WPS Office: fix running window icon on wayland
And now delete the wps cloud server program entirely
1 parent 6b2ad7a commit 9d7d23d

2 files changed

Lines changed: 58 additions & 5 deletions

File tree

apps/WPS Office/install-64

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,55 @@ wget --header="User-Agent: This download is a result of the Pi-Apps store. Pleas
2222

2323
#install libwebp6 and libtiff5 to get PDF export working
2424
if package_available libwebp6 && package_available libtiff5 ;then
25-
install_packages "$firejail_package" /tmp/wps-office.deb libwebp6 libtiff5 ttf-mscorefonts-installer || exit 1
25+
install_packages "$firejail_package" /tmp/wps-office.deb libwebp6 libtiff5 ttf-mscorefonts-installer x11-utils wmctrl || exit 1
2626
else
27-
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
27+
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
2828
fi
2929
rm -f /tmp/wps-office.deb
3030

31-
#Prevent application from connecting to the internet
32-
sudo sed -i 's|^Exec=|Exec=firejail --net=none --noblacklist=~/.local/share/Kingsoft --noblacklist=~/.config/Kingsoft |g' /usr/share/applications/wps*.desktop
33-
rm -f ~/Desktop/wps-office-prometheus.desktop
31+
#make icon symlinks that correspond to WM_CLASS so correct icon is set on Wayland (for main wps window only)
32+
while read file ;do
33+
sudo ln -sf "$file" "$(echo "$file" | sed 's+/mimetypes/+/apps/+g ; s+/wps-office2019-kprometheus.png$+/'"wpsoffice.png+g")"
34+
done < <(dpkg -L wps-office | grep -x '/usr/share/icons/hicolor/.*/mimetypes/wps-office2019-kprometheus.png$')
35+
36+
sudo update-icon-caches /usr/share/icons/*
37+
sudo xdg-icon-resource forceupdate --mode system
38+
39+
#Prevent application from connecting to the internet - use runner scripts
40+
sudo rm -f /home/*/.local/share/applications/wps*.desktop /home/*/Desktop/wps*.desktop #remove wps-generated .desktop files
41+
sudo rm -f /opt/kingsoft/wps-office/office6/wpscloudsvr #remove cloud and sign-in features - prevent this unnecessary background process
42+
43+
#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)
44+
sudo sed -i 's|firejail --net=none --noblacklist=~/.local/share/Kingsoft --noblacklist=~/.config/Kingsoft ||g ;
45+
s|^Exec=/usr/bin|Exec=/usr/local/bin|g ; s/%U/%F/g' /usr/share/applications/wps*.desktop
46+
47+
#Make runner scripts in /usr/local/bin to use firejail and to fix window icon on wayland by changing WM_CLASS
48+
make_wps_script() {
49+
command=$1
50+
old_wm_class=$2
51+
new_wm_class=$3
52+
53+
cat <<EOF | sudo tee /usr/local/bin/$command >/dev/null
54+
#!/bin/bash
55+
56+
rm -f ~/Desktop/wps*.desktop ~/.local/share/applications/wps*.desktop
57+
58+
(for i in {0..20};do
59+
sleep 0.5
60+
while read id ;do
61+
xprop -f WM_CLASS 8s -set WM_CLASS "$new_wm_class" -id "\$id" 2>/dev/null
62+
done < <(wmctrl -lx | grep -F ' $old_wm_class ' | awk '{print \$1}')
63+
done) &
64+
65+
firejail --noprofile --net=none --noblacklist=~/.local/share/Kingsoft --noblacklist=~/.config/Kingsoft /usr/bin/$command "\$@"
66+
67+
rm -f ~/Desktop/wps*.desktop ~/.local/share/applications/wps*.desktop=
68+
EOF
69+
sudo chmod +x /usr/local/bin/$command
70+
}
71+
72+
make_wps_script wps wps.wps wps-office2019-wpsmain
73+
make_wps_script wpspdf wpspdf.wps wps-office2019-pdfmain
74+
make_wps_script wpp wpp.wpp wps-office2019-wppmain
75+
make_wps_script et et.et wps-office2019-etmain
76+

apps/WPS Office/uninstall

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@ if [ -d /opt/wps-office-chroot ];then
2222

2323
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
2424

25+
else
26+
#on 64-bit - remove files that were added by the install-64 script
27+
28+
#remove icon symlinks
29+
sudo rm -f /usr/share/icons/hicolor/*/apps/wpsoffice.png
30+
#remove runner scripts
31+
sudo rm -f /usr/local/bin/wps
32+
sudo rm -f /usr/local/bin/wpspdf
33+
sudo rm -f /usr/local/bin/wpp
34+
sudo rm -f /usr/local/bin/et
2535
fi
2636

2737
purge_packages || exit 1

0 commit comments

Comments
 (0)