Is there a way to change the icon of an application's window from the command line?

For instance, I'd like to have separate icons for Firefox windows under different profiles (different processes), change the icon of the terminal if it runs tmux, etc.

By 'icon' I mean the small picture shown by window switcher, typically invoked with Alt+Tab. In particular, I'm interested for this to work under xfwm4, but a more general solution would only be welcome.

Apparently, neither xdotool nor wmctrl are capable of this.


xseticon allows you to do exactly that.

| improve this answer | |

If you run xprop and click on a window, you see that the icon is among the "metadata" assigned to the window structure in your X server, under name and type _NET_WM_ICON(CARDINAL). These parameters can be changed by other X applications, for instance, window managers write and change a whole bunch of stuff in there. The key function will be XChangeProperty.

I'm not aware of any tools that do this easily from commandline but this doesn't mean they don't exist.

In any case, it could be written from scratch, it's not hard (even though writing in raw xlib will make your chest hair stand on end and probably give you PTSD).

| improve this answer | |
  • I have tried xseticon as recommended by @dakatine. It uses _NET_WM_ICON, and has changed the icon, in the top left corner (in the title bar). However there is no change in the task-bar, or system tray (when an app has an icon here). Do you know why the task-bar is not changing. – ctrl-alt-delor Sep 10 '17 at 12:48

It could be different for different OSes / flavours. Mostly by editing the desktop file directly at /usr/share/applications or by copying or creating the desktop file at /home/username/.local/share/applications/ , this could be achieved.


Please refer http://standards.freedesktop.org/desktop-entry-spec/latest/ar01s05.html

| improve this answer | |
  • 1
    Yhank you, I know that. I need to change the icon of a window dynamically; I suppose it's somehow standard under X11. – 9000 Jan 15 '15 at 14:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.