正如评论中提到的,一个应用程序原则上一次只能由启动器中的一个图标表示。情况一直如此。
您所指的可能是 Unity 在确定哪个.desktop文件最能代表应用程序窗口方面变得“更聪明” 。因此,运行终端窗口的脚本将由gnome-terminal-icon表示:
因此,过去在您的设置中起作用的方法,只需创建一个启动器,启动您的脚本,就不再欺骗 Unity,它会选择现有的gnome-terminal启动器来代表您的窗口。
...是通过在启动器中添加一行来否决 Unity 的选择(对于 16.04):
StartupWMClass=gnome-terminal-server
Run Code Online (Sandbox Code Playgroud)
...但是所有终端窗口,无论它们是否运行您的脚本,都在此图标下分组。
此外,一般来说,拥有多个.desktop文件,在它们的主命令中调用同一个应用程序是不好的、不干净的做法。
这需要一些弄虚作假和欺骗的,但它是可以有多个脚本一个单独的图标,在不同的终端窗口运行。
somscript.sh您希望在终端窗口中运行该脚本,并在运行时在 Unity Launcher 中显示其专用图标。运行命令:
showicon somescript.sh someicon.png
Run Code Online (Sandbox Code Playgroud)
脚本将在新打开的gnome-terminal窗口中运行,显示图标:someicon.png
我想要一个脚本,/home/jacob/Bureaublad/script.sh运行,显示在带有图标的 Unity 启动器中:/home/jacob/Thema/icon/ubu.png
运行命令:
showicon '/home/jacob/Bureaublad/script.sh' '/home/jacob/Thema/icon/ubu.png'
Run Code Online (Sandbox Code Playgroud)
会这样做:
现在让我们添加另一个:
showicon '/home/jacob/Bureaublad/script2.sh' '/home/jacob/Thema/icon/banaan.png'
Run Code Online (Sandbox Code Playgroud)
结果:
关闭窗口后,将再次删除图标。
脚本需要 wmctrl
sudo apt-get install wmctrl
Run Code Online (Sandbox Code Playgroud)创建,如果它还不存在,目录 ~/bin
showicon(无扩展名)~/bin,并使其可执行注销并重新登录,您的设置应该可以工作。用命令测试一下
showicon </path/to/script.sh> </path/to/icon.png>
Run Code Online (Sandbox Code Playgroud)
已经script.sh在终端上运行,显示出icon.png在Unity启动器。
StartupWMClass=gnome-terminal-server
Run Code Online (Sandbox Code Playgroud)
图标的作用:
gnome-terminal窗口,运行你的脚本单击它时,它会像往常一样升起窗口。执行此操作的命令会自动添加到临时启动器中:
wmctrl -ia <window_id>
Run Code Online (Sandbox Code Playgroud)它没有什么:
无需过多赘述:
showicon, 的实例showicon将在gnome-terminal窗口中运行您的脚本,类似于Terminal=true.showicon等待新gnome-terminal窗口出现并读取其窗口 ID。然后创建一个临时启动器,使用窗口 id 创建命令以在其Exec=行中提升窗口。您在要运行的命令中设置为参数的图标showicon会自动设置为此临时启动器的图标(在 行中定义Icon=)。
这种自动创建(临时)启动器的示例:
[Desktop Entry]
Type=Application
Exec=wmctrl -ia 0x04400b7f
Name=script2.sh
Icon=/home/jacob/Thema/icon/ubu.png
StartupNotify=False
Run Code Online (Sandbox Code Playgroud)使用与此答案完全相同的过程,将临时启动器添加到 Unity Launcher 的顶部位置,以表示您正在运行的脚本。
showicon检查窗口是否存在。如果不(再),临时发射器从发射团结移除并从存在删除所有和showicon实例终止。