Change Application Window Icons Elegantly

The situation

Sometimes you want to change the icon an application displays e.g. in the panel but cannot for some reason.

  • Changing the icon theme does not help, and the application has no means of telling it to use another icon.
  • Changing the icon referenced in the software's .desktop file (usually installed to /usr/share/applications when the software was installed) doesn't help either.
  • Putting a suitable icon inside the icon theme's folders or under, say, /usr/share/pixmaps or /usr/share/icons/hicolor doesn't help either!

The solution

(under Xorg)

If you can get your hands on fbpanel (for Archlinux users, instead of compiling from source), install it. We will use it not as a panel, but only for its "icons" plugin that allows to replace troublesome icons with nicer ones.

Save this as ~/.config/fbpanel/default and edit the Plugin section to your content (the Global section just ensures the panel itself stays invisible):

Global {
    edge = bottom
    allign = right
    margin = 0
    widthtype = pixel
    heightType = pixel
    width = 0
    height = 0
    transparent = true
    alpha = 0
    setdocktype = false
    setpartialstrut = false
    autohide = false
    heightWhenHidden = 0
    roundcorners = false
    layer = below
    SetLayer = false
    MaxElemHeight = 0
}

# 'icons' plugin lets you customize window icons.
# these changes apply to entire desktop
Plugin {
    type = icons
    config {
        application {
            icon = utilities-terminal
            #terminal-symbolic
            ClassName = URxvt
        }
        application {
            icon = web-browser
            ClassName = Firefox
        }
        application {
            icon = extract-archive
            ClassName = Engrampa
        }
        application {
            icon =  /path/to/icon.png
            ClassName = Xmessage
        }
        application {
            icon =  accessories-calculator
            ClassName = XCalc
        }
    }
}

As you can see you can use both symbolic names or full paths to image files (just like inside .desktop files). Applications are identified by their ClassNames, these can be found like so: xprop|grep WM_CLASS

Now just add fbpanel & to your autostart. There will be no panel, you can still use your other panel! All this does is to magically change icons. The changes are instant both for running & newly started applications.

More explanation here.

Inferior solution

The application xseticon essentially does the same, but it has to be activated manually, resulting in ugly hacks like wrapper scripts around executables and a perceptible flicker when the icon changes. But it might be a better solution in some cases.