8

I'm running KDE on Arch Linux. I have the following two .desktop files.

[Desktop Entry]
Comment=First Profile
Exec=firefox --no-remote -P First %u
GenericName=Firefox First Profile
Icon=/path/to/custom/icon1.png
Name=FF_First
NoDisplay=false
Path[$e]=
StartupNotify=true
Terminal=0
TerminalOptions=
Type=Application
X-KDE-SubstituteUID=false
X-KDE-Username=

[Desktop Entry]
Comment=Second Profile
Exec=firefox --no-remote -P Second %u
GenericName=Firefox Second Profile
Icon=/path/to/custom/icon2.png
Name=FF_Second
NoDisplay=false
Path[$e]=
StartupNotify=true
Terminal=0
TerminalOptions=
Type=Application
X-KDE-SubstituteUID=false
X-KDE-Username=

When I initially launch one of these Firefox profiles, the icon that shows up in the task manager bar in Plasma's panel is the custom icon I specified in the .desktop file. But as soon as Firefox has finished starting up, the icon in the task manager (Plasma panel) reverts to the standard Firefox icon. How do I make my custom icon stick in the task manager panel on a per profile basis?

One approach I tried was creating a separate shell script to launch each profile, but that resulted in the same outcome: once Firefox is launched, every profile shows with the same generic Firefox icon in the task manager.

There is a similar question here, but it is not about icons per Firefox profile and it doesn't answer my question.

Update: based on the answer by fra-san, here is my updated desktop entry:

[Desktop Entry]
Comment=Second Profile
Exec=firefox -P Second --class=FFSecond
GenericName=Firefox Second Profile
Icon=/home/allusers/application_icons/Second/Firefox_Logo_128x128.png
Name=FFSecond
NoDisplay=false
Path[]=
StartupNotify=true
Terminal=0
TerminalOptions=
Type=Application
Categories=Network;WebBrowser
X-KDE-SubstituteUID=false
X-KDE-Username=
StartupWMClass=FFSecond

I am not getting results yet. The above entry displays the standard firefox icon in the tabs in the "Task Manager" widget of KDE Plasma's Panel, exactly the same as the standard firefox desktop file does.

I tried the Exec line with -no-remote, with -new-instance and without either and there was no difference in terms of the icon.

As mentioned, I want each Firefox profile to display its custom icon in the tabs in the "Task Manager" widget of KDE Plasma's Panel.

1 Answer 1

8
+50

I hope I have understood your question correctly. I assume the icons you are talking of are those of the tabs in the "Task Manager" widget of KDE Plasma's Panel.

It looks like your question has an answer on askubuntu. There, the question mentions Ubuntu and Gnome, but the answer does not make use of any specific feature of a desktop environment or Linux distribution. I tested it on Arch Linux with KDE Plasma 5.14.4, Firefox 63.0.3, X.Org X Server 1.20.3.

It boils down to a couple of edits to your .desktop files:

1) Add the --class option to the Exec key. It is briefly documented on MDN:

--class=WM_CLASS
Set the WM_CLASS resource class of the X11 windows created by the application.

2) Add the StartupWMClass key. It is briefly documented in the Desktop Entry Specification by freedesktop.org:

StartupWMClass
If specified, it is known that the application will map at least one window with the given string as its WM class or WM name hint (see the Startup Notification Protocol Specification for more details).

With these two options, each instance of Firefox is given its own WMCLASS, so that instances are not grouped together in the "Task Manager". The StartupWMClass sets a link between open Firefox windows and the desktop entries that launched them, letting them keep their custom icons.

To provide an example, assuming your two .desktop files as the starting point and omitting the lines that are not relevant here:

[Desktop Entry]
Comment=First Profile
...
Exec=firefox --no-remote -P test1 --class=firstclass %u
...
StartupWMClass=firstclass
[Desktop Entry]
Comment=Second Profile
...
Exec=firefox --no-remote -P test1 --class=secondclass %u
...
StartupWMClass=secondclass
7
  • Yes, I am talking of are the icons of the tabs in the "Task Manager" widget of KDE Plasma's Panel.
    – MountainX
    Dec 2, 2018 at 3:35
  • 1
    Great answer! I believe it should work, but so far it is not. (My lack of results is similar to the OP on the AskUbuntu question you linked.) Your explanation is very clear; I don't think I am missing any steps. I'm running Arch Linux with KDE Plasma 5.14.3, Firefox 63.0.3, X.Org 1.20.3. The window properties of Firefox launched with the .desktop file as per your answer, are detected as Window class: firefox (navigator firefox), Window role: browser. What else can we compare to find the differences between your system, where it works, and my system, where it does not work?
    – MountainX
    Dec 2, 2018 at 4:16
  • 1
    I grabbed your icons and your last .desktop file, changed only icon's path and profile name, and it worked here. How did you get your window properties? I used xprop WM_CLASS, got WM_CLASS(STRING) = "Navigator", "FFSecond" (same results with More Actions (from Firefox title bar) > Special Window Settings > Window Matching > Detect Window Properties). It looks like your system is not honoring the --class option. I'll try digging into it a bit more. The minor difference in Plasma version (5.14.4 VS 5.14.3) should not be an issue (I glanced at the changelog), but we should not forget it.
    – fra-san
    Dec 2, 2018 at 10:15
  • 1
    I tried your approach on a different computer (my laptop) and it worked perfectly! My laptop and desktop both run Arch Linux and (as far as I can tell) they are set up exactly the same. It would be nice to know what minor settings can cause this solution to not work. To get window props I used both xprop WM_CLASS and KDE's KWin Window-Specific Settings dialog. One difference I noticed is that KDE's tool returns an all lower case string. On my laptop a class string name of mixed casing works even though KDE's tool forces the string to lowercase. Anyway, this is progress! Thanks
    – MountainX
    Dec 2, 2018 at 23:32
  • 2
    This solution is working on my desktop too now. Unfortunately, I cannot say what, if any, change made it start working. It just started working and I don't think I changed anything or even rebooted. The takeaway for anyone else who wants this solution may be that if it doesn't work, keep trying.
    – MountainX
    Dec 3, 2018 at 0:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .