Sunday, April 28, 2024
 Popular · Latest · Hot · Upcoming
4
rated 0 times [  4] [ 0]  / answers: 1 / hits: 2464  / 2 Years ago, sat, december 18, 2021, 1:00:32

I have two separate .desktop files locked to the panel. Both of them opens terminal windows and runs a series of commands (with user input). Trouble is, while one is opened already, opening the other results in both of them getting grouped together under the same one (one which was opened first). This is a bit troubling since..say if I opened a terminal window by ctrl+alt+t shortcut, instead of opening a new icon in the panel, it gets added in to the already opened .desktop file!



I'm running Ubuntu 12.10 with unity interface.


More From » unity

 Answers
3

I think the problem could be for the WM_CLASS(STRING) in the gnome-terminal's window properties


If you have two desktop files with different icons but running gnome-terminals... you can check the WM_CLASS with the command xprop



  • xprop | grep WM_CLASS


Then click in the windows (with the cross cursor)... and the result for your applications should be:



WM_CLASS(STRING) = "gnome-terminal", "Gnome-terminal"



In my opinion, due to the windows have the same WM_CLASS they will be grouped together in the Unity Launcher.




Set Class & Name in Gnome-Terminal


To avoid this issue you can try to set a different WM_CLASS string for each desktop file.


The command should be:



  • gnome-terminal --disable-factory --class <appname> --name <appname>


Here you have an example to run gnome-terminal & execute a little script.



  • gnome-terminal --disable-factory --class term-red --name term-red --title Term-Red --window-with-profile=red -e '/home/virtual/Desktop/test1.sh'




Example with 2 desktop files.


I created 2 desktop files that will run scripts (using gnome-terminal), and the gnome-terminal desktop icon locked to the Unity Launcher.


1) gnome-terminal.desktop
2) term-green.desktop
3) term-red.desktop.


enter image description here


When I click in the 3 desktop files they are not grouped under the same icon.


enter image description here


As you can see 3 Terminals are running (with their own icon).


enter image description here


Here you have the content of the term-red.desktop.


enter image description here


The important keys to add in your .desktop files would be:



  • Exec=gnome-terminal --disable-factory --class term-red --name term-red --title Term-Red --window-with-profile=red -e '/home/virtual/Desktop/test1.sh'

  • StartupWMClass=term-red

  • StartupNotify=true


Here you have information about Desktop Entry Specification.




Another option would be to run xterm instead gnome-terminal.
xterm will accept the option class & name.



  • Exec=uxterm -class term-red -name term-red -T Term-Red -e '/home/virtual/Desktop/test1.sh'


NOTE: Please change these examples according to your neeeds.


Hope it helps.


[#29593] Sunday, December 19, 2021, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
montwim

Total Points: 103
Total Questions: 112
Total Answers: 120

Location: Vietnam
Member since Mon, Mar 14, 2022
2 Years ago
;