Page 1 of 1

How to change panel/taskbar icon for running program

Posted: Tue May 14, 2019 1:36 pm
by nuverb
I have written a program in C++ and created a desktop shortcut to start it. I also assigned an icon to the shortcut.
However, when I run the program, the icon that appears on the panel/taskbar to represent the running program is a plain window.
My panel/taskbar is on the right hand side and the icon is at the bottom, like this: Image

How do I change the panel/taskbar icon to match the one in my desktop shortcut?

Thank You

Re: How to change panel/taskbar icon for running program

Posted: Fri May 17, 2019 8:07 pm
by nuverb
I found the answer to my own question. I am using GTKmm (with C++) and there is a function to set the icon for when a program is minimized. In the main window's constructor you put this:
MainWindow::MainWindow()
{
if(!set_icon_from_file("icon.png") info_box("Can't find taskbar icon");
}

Instead of icon.png put the path name to your icon.
info_box() is a function to display a message using MessageDialog

If someone is writing a Python program there may be similar function.

Re: How to change panel/taskbar icon for running program

Posted: Fri May 17, 2019 8:58 pm
by Andyroo
I get the feeling that the run-time icon is due to your app icon not being in a theme.

I think (and have no desktop Pi handy) if the icon is put in /usr/share/icons (possibly /hicolor/48x48/apps/ under that) you should get the same icon when running. At least in your way you can change it depending on program status :)