Score:1

How can I set a custom icon for firefox running through firejail? (not only for the launcher but also for the running app itself)

ua flag

My specs: Ubuntu 20.04.3 with Gnome Shell on Wayland. Notebook Acer Aspire 5 with AMD Ryzen 7 5700U.

For my work, I want to run Firefox through the sandboxing utility firejail. I created a custom *.desktop file to launch the "firejailed" firefox and placed it in ~/local/share/applications.

In the *.desktop file, I specified a custom icon (the blue Firefox icon that is used for the nightly builds) and the custom launcher uses this blue icon. Ok, fine.

When I run the launcher, the "firejailed" Firefox starts and runs correctly but the icon that is displayed in the window overview and in the task bar (or dock) is the standard Firefox icon (orange/yellow) not the blue one I specified.

What I have to do so that the running "firejailed" Firefox is displayed in Gnome Shell with the blue icon?

Here is how my *.desktop file looks like:

[Desktop Entry]
Version=1.1
Type=Application
Name=Firefox Work
Comment=Web Browser configurated for Work
Icon=firefox-nightly
Exec=firejail --private=/home/nuri/.firejail-firefox/ firefox -no-remote
Actions=
Categories=Network;
StartupNotify=true
kanehekili avatar
zw flag
Check [my answer](https://askubuntu.com/a/1380840/906933) for a similar problem. Note he first "xdg" line
nuri avatar
ua flag
Thanks for your answer but it makes no difference. I add the line "#!/usr/bin/env xdg-open" to the *.desktop file before "[Desktop Entry]". Then I started the firejailed-firefox from the shell and the normal orange icon is displayed :-(
Score:2
cn flag

Have this specific instance of firefox launch with a specific WMClass by adding the option

--class=CLASS

where CLASS is a name of your choosing, e.g. fjfox.

Then connect your custom .desktop laucher to that WMCLass by adding a line as

StartupWMClass=CLASS

See the answer of nuri for a full example of the desktop file.

nuri avatar
ua flag
Thanks vanadium, it works.
raj avatar
cn flag
raj
@vanadium does this method work for other programs as well, not only Firefox?
vanadium avatar
cn flag
@raj The option `--class=CLASS` will work with all GTK programs, and also Firefox and LibreOffice, which have a "GTK skin".
nuri avatar
ua flag
...and the same with VirtualBox, but without firejail? (in the Ubuntu dock, I want to see the icon of the app that is running in the virtual Windows 10, not the generic VirtualBox icon). Should I open a new question?
vanadium avatar
cn flag
Do not hesitate to try it out yourself.
Score:1
ua flag

For those who want to have the practical solution, the working *.desktop file looks now like this:

Version=1.1
Type=Application
Name=Firefox Arbeit
Comment=Web Browser configurated for Work
Icon=firefox-nightly
Exec=firejail --private=/home/nuri/.firejail-firefox/ firefox -no-remote --class=fjfox
Actions=
Categories=Network;
StartupNotify=true
StartupWMClass=fjfox
nuri avatar
ua flag
This doesn't work anymore in Ubuntu 22.04, the blue icon is again replaced by the normal Firefox icon when Firefox is running. Any idea?
Score:0
ua flag

In Ubuntu 22.04 running Wayland, you have to change the .desktop file as above. Use --name instead of --class= in the Exec line.

Version=1.1
Type=Application
Name=Firefox Arbeit
Comment=Web Browser configurated for Work
Icon=firefox-nightly
Exec=firejail --private=/home/nuri/.firejail-firefox/ firefox --no-remote --name fjfox
Categories=Network;
StartupNotify=true
StartupWMClass=fjfox
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.