问题描述
当我们打开应用程序之后,在 GNOME 的 Dock 中,将显示应用图标。在应用图标上右键,将显示 Add to Favorites 选项,已将图标固定在 Dock 上,方便下次打开。
但是,有些应用程序却没有 Add to Favorites 选项(比如 Eclipse 应用)
问题原因
窗口的 WM_CLASS 属性,与在 .desktop 中的 StartupWMClass 属性不匹配。
解决方法
我们这里以 Eclipse 窗口为例:
第一步,执行 xprop WM_CLASS 获取窗口的 WM_CLASS 属性:
# xprop WM_CLASS WM_CLASS(STRING) = "Eclipse", "Eclipse"
第二步、修改 Eclipse 的 .desktop 文件的 StartupWMClass 属性:
# eclipse.desktop ... StartupWMClass=Eclipse ...
至此,问题就得以解决(需要重启 Eclipse 之后才显示):
参考文献
WikiNotes/关于选项 Add to Favorites 显示问题
gnome shell - Cannot add custom launcher to Ubuntu Dock ('Add to Favorites' option does not show up) - Ask Ubuntu
Duplicate icons for manually created GNOME launcher items - Ask Ubuntu