KDE 下 Chrome 的 webapp 不显示图标
最近从 Firefox 更换到 Chrome 上来,发现 Chrome 的 pwa 可以替代一些软件,比如 spotify
但是在 KDE 下有个问题,就是这些 pwa 应用的图标都会重定向到 Chrome 图标,缺少了辨识度
另外,有些图标主题并没办法展示 Chrome 的 pwa 图标,比如 Tela,这个时候需要自己修改.desktop 文件的 ico 参数了
关于 pwa 应用图标重定向问题,可以通过更改窗口运行方式解决
首先安装 xdotool
然后修改位于 ~/.local/share/applications/ 的文件,将 && xdotool search --sync --classname <value> set_window --class <value> 添加到 Exec 行后面,其中 <value> 替换成 StartupWmClass 的值
通过脚本实现
#!/bin/bash
set -e
DIR="$HOME/.local/share/applications"
PATTERN="chrome-*.desktop"
if ! command -v xdotool > /dev/null; then
echo "installing xdotool..."
yes | sudo pacman -S xdotool
fi
for file in $(ls $DIR/$PATTERN)
do
echo "$file:"
ID=$(grep -m 1 Exec $file | sed -E 's/^(.*)--app-id=(\w*).*$/\2/g')
CMD=" \&\& xdotool search --sync --classname $ID set_window --class $ID"
if grep -q "$CMD" $file; then
echo " skip file"
continue
fi
echo " changing file"
sed -E -i 's!^(Exec=)(.*)$!\1\2'"${CMD}"'!g' $file
done
echo "updating desktop database"
update-desktop-database $DIR
echo "done"