Score:1

One terminal app; two (Favorites) launch modes

cn flag

Running Ubuntu 20.04, I wish to have two clickable launch modes for gnome-terminal in the Favorites bar [i.e. in the "Dock"]. For example, I want both the default launch and a bespoke launch. The default launcher was trivial to add to the Favorites bar, using the well-known mechanisms. For the custom launcher, I created the following .desktop file:

$ cat ~/.local/share/applications/custom-terminal.desktop 
[Desktop Entry]
Type=Application
Encoding=UTF-8
Name=CustomTerminal
Comment=Terminal for Specialized Development
Exec=$HOME/.bin/custom-terminal.sh
Icon=/usr/share/icons/gnome/48x48/apps/gnome-terminal.png
Terminal=false

For the bespoke launch, I set an environment variable (FOOBAR) by which my ~/.bashrc file can invoke custom logic:

$ cat $HOME/.bin/custom-terminal.sh
#!/bin/bash
FOOBAR=SomeTriggerValue /usr/bin/gnome-terminal

PROBLEM: I can add the custom launcher to the Favorites bar, but the launched instance is incorrectly associated to the default launcher's icon. i.e. The default launcher's icon [in the Favorites bar] gets the "red dot" for my custom instance of gnome-terminal.

I have tried making copies of the executable [of course, having different paths] to "fool" the desktop into believing that the one app is actually two, but that gimmick failed.

I noticed that if I right-click on the default gnome-terminal icon, then I'm offered a Preferences option. A right-click on the custom gnome-terminal icon does not offer a Preferences option.

QUESTION: How to add 2+ custom launchers for gnome-terminal to the Favorites bar?

Score:0
cn flag

The Ubuntu launcher distinguishes running applications based on the WMClass. You should do two things

  • ensure that the terminal from the custom launcher adopts a different WM_CLASS than the default.
  • declare that custom WM_CLASS in the launcher using a StartupWMClass= directive.

See gnome-terminal --help-gtk for the option on how to set your own WM_CLASS.

badfd avatar
cn flag
Worked like a charm. Thank you.
vanadium avatar
cn flag
If this answer helped, then please consider "accepting" it, i.e., click the checkmark next to the question. This helps future users.
badfd avatar
cn flag
Done. Sorry for the delay. I asked myself, "How to 'accept' this answer?"
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.