I’m a heavy user of Firefox profiles. Apart from using different profiles for different activities, I also have a few extra profiles that all run in the Default activity.

This means that I need to have different icons shown in Plasma’s panel in order to be able to easily differentiate which profile a window belongs to.

Sure, I use the tasks applet which shows the window title instead of the icon-only one (I prefer usability to minimalism), but still, it isn’t enough as sometimes the active tab in a Firefox window might not have the most informative title.

Plasma seems to rely on the application name and the window class when choosing the icon it will show in the panel. Which means that, by default, all Firefox instances end up having the same icon.

Librewolf with a custom profile icon
Librewolf with a custom profile icon

Fortunately, Firefox allows you to specify the window class it should use through command line arguments.

firefox -P ProfileName --class WindowClassName

And, to connect a launcher to a specific window class, you just need to add the following line to the .desktop file:

StartupWMClass=WindowClassName

So, in order to have a nicely supported Firefox profile, you can create a launcher with a desktop file similar to the following:

[Desktop entry]
Exec=firefox -P SocialSites --class FirefoxSocialSites
Icon=user-available-symbolic
StartupWMClass=FirefoxSocialSites

It also works with Firefox derivatives such as Librewolf (which can be seen in the screenshot above) and others.

Wayland

For Wayland users, a comment by John Kizer might be useful:

On Wayland, I’ve ended up just using KWin Window Rules (based on a substring of the window title, and setting the desktop file name) in combination with .desktop files that launch Firefox to the site in question and have the desired icon associated.

EDIT: And another approach for Wayland by Christoph Martin:

There’s no need for messing around with window rules - at least not for Firefox.

If you use the –main flag instead of the –class flag for the Firefox invocation in your .desktop file, you should get the desired effect - at least in the Icons-Only Task Manager. Note that StartupWMClass still needs to match the value of the –main flag.

The above works on my machine, that is under Plasma 6.0.5 on the Fedora 40 KDE spin.

Credit: https://superuser.com/a/1784867