现象:Paseo 已固定到 GNOME 任务栏(收藏夹),从任务栏图标启动后,打开窗口与固定图标不合并,显示为两个独立图标。

环境:Ubuntu + GNOME Shell,Paseo 安装在 /opt/Paseo/。

诊断过程(可复现)

1. 定位 Desktop Entry

rg -i --files /usr/share/applications | rg -i 'paeso|paseo'

输出:

/usr/share/applications/Paseo.desktop

读取原始文件:

sed -n '1,200p' /usr/share/applications/Paseo.desktop

原内容关键项:

Exec=/opt/Paseo/Paseo %U
StartupWMClass=Paseo

2. 检查当前收藏夹 desktop id

gsettings get org.gnome.shell favorite-apps

可见收藏项中使用 Paseo.desktop。

3. 从日志确认窗口类线索

journalctl --user -b --no-pager | rg -i 'paseo|wmclass|app id' | tail -n 120

关键线索:

Started app-Paseo.bin-1901082.scope.

这通常意味着窗口类/应用识别更接近 Paseo.bin,与原 StartupWMClass=Paseo 不一致,导致任务栏匹配失败。

现场命令输出补充(原始记录)

dev@devhost:~$ cat /usr/share/applications/Paseo.desktop
[Desktop Entry]
Name=Paseo
Exec=/opt/Paseo/Paseo %U
Terminal=false
Type=Application
Icon=Paseo
StartupWMClass=Paseo
Comment=Paseo desktop app (Electron wrapper)
Categories=Development;
dev@devhost:~$
dev@devhost:~$ cat ~/.local/share/applications/Paseo.desktop
[Desktop Entry]
Name=Paseo
Exec=/opt/Paseo/Paseo %U
Terminal=false
Type=Application
Icon=Paseo
StartupWMClass=Paseo.bin
X-GNOME-WMClass=Paseo.bin
Comment=Paseo desktop app (Electron wrapper)
Categories=Development;
dev@devhost:~$
dev@devhost:~$ cat /opt/Paseo/Paseo
#!/bin/bash
exec "$(dirname "$(readlink -f "$0")")/Paseo.bin" --no-sandbox "$@"
dev@devhost:~$
dev@devhost:~$ ls -lh /opt/Paseo/Paseo.bin
-rwxr-xr-x 1 root root 197M  4月 16 23:15 /opt/Paseo/Paseo.bin
dev@devhost:~$
dev@devhost:~$ file /opt/Paseo/Paseo.bin
/opt/Paseo/Paseo.bin: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=bb7c19abf4fef1dba088a8a3595b42c17e188af8, stripped
dev@devhost:~$

修复方案(最终采用)

采用用户级覆盖(不改系统文件):新建 ~/.local/share/applications/Paseo.desktop,让 GNOME 优先读取本地条目。

mkdir -p ~/.local/share/applications
cat > ~/.local/share/applications/Paseo.desktop <<'INI'
[Desktop Entry]
Name=Paseo
Exec=/opt/Paseo/Paseo %U
Terminal=false
Type=Application
Icon=Paseo
StartupWMClass=Paseo.bin
X-GNOME-WMClass=Paseo.bin
Comment=Paseo desktop app (Electron wrapper)
Categories=Development;
INI

update-desktop-database ~/.local/share/applications

校验:

desktop-file-validate ~/.local/share/applications/Paseo.desktop

关于 --class=Paseo.bin 的补充说明

  • 该参数是 Chromium/Electron 在 Linux 下可识别的窗口类覆盖参数(主要用于 X11 的 WM_CLASS 匹配)。
  • Paseo 启动脚本会透传参数给 Paseo.bin,所以此前添加该参数是可生效的兜底方式。
  • 本机当前为 Wayland 会话(XDG_SESSION_TYPE=wayland),任务栏合并通常主要依赖 desktop file id / app_id,因此在 StartupWMClass 已对齐后,Exec 保持默认写法也可以正常合并。

验证步骤

  1. 完全退出 Paseo(托盘也退出)。
  2. 从任务栏固定图标重新启动 Paseo。
  3. 检查是否仍出现“固定图标 + 独立运行图标”分离现象。

若仍异常,可执行:

# 取消固定
# 再次从应用列表启动 Paseo 后重新固定

回滚

删除本地覆盖文件即可恢复系统默认行为:

rm -f ~/.local/share/applications/Paseo.desktop
update-desktop-database ~/.local/share/applications