# Taskbar icon in Linux Gnome 3.38.3 (Ubuntu 20.10)

**URL:** https://discourse.glfw.org/t/taskbar-icon-in-linux-gnome-3-38-3-ubuntu-20-10/1769
**Category:** support
**Created:** [February 18, 2021, 12:02am UTC](https://discourse.glfw.org/t/taskbar-icon-in-linux-gnome-3-38-3-ubuntu-20-10/1769 "2021-02-18T00:02:31Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![erith835](https://avatars.discourse-cdn.com/v4/letter/e/e8c25b/32.png) [@erith835](https://discourse.glfw.org/u/erith835)
#### Post date: [February 18, 2021, 12:02am UTC](https://discourse.glfw.org/t/taskbar-icon-in-linux-gnome-3-38-3-ubuntu-20-10/1769/1 "2021-02-18T00:02:31Z")

</div>

How can I set the icon of my GLFW app in the **task bar** in my Ubuntu Linux 20.10 (Gnome 3.38.3)?

I have tried to create a so called Desktop entry in `~/.local/share/applications` and that works for a simple gtkmm app but not for my GLFW app.

I have also tried to use `glfwSetWindowIcon()` but that has no effect.

The icon in the task bar is always empty. Here is what my task bar looks like with one gtkmm app with an icon from the corresponding desktop entry and below it the empty icon of my GLFW app which also has a similar desktop entry.  
 ![image](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/df363733e6d3a4398ed505a43f892c015e889fae.png)

OS Name: Ubuntu Linux 20.10  
OS Type: 64 bit  
GNOME Version 3.38.3  
Windowing system: X11  
GLFW Version: 3.3

Thank you for your help

---

<div class="post-metadata">

### Author: ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)
#### Post date: [February 18, 2021, 2:15pm UTC](https://discourse.glfw.org/t/taskbar-icon-in-linux-gnome-3-38-3-ubuntu-20-10/1769/2 "2021-02-18T14:15:55Z")

</div>

Have you tried the GLFW test program [icon.c](https://github.com/glfw/glfw/blob/master/tests/icon.c)?

If that works, then it’s possible you are setting the alpha value to 0, so it ends up transparent - the icon format is 32bit RGBA (i.e. 8bits per channel, 4th value is alpha).

Checking the issues list I found an open issue concerning X11 and `glfwSetWindowIcon()`:

> <https://github.com/glfw/glfw/issues/1375>
>
> On linux (x11 and wayland, I haven't tested mac) some functions don't seem to work if they are called right after...

---

<div class="post-metadata">

### Author: ![erith835](https://avatars.discourse-cdn.com/v4/letter/e/e8c25b/32.png) [@erith835](https://discourse.glfw.org/u/erith835)
#### Post date: [February 19, 2021, 7:09am UTC](https://discourse.glfw.org/t/taskbar-icon-in-linux-gnome-3-38-3-ubuntu-20-10/1769/3 "2021-02-19T07:09:54Z")

</div>

Thank you dougbinks, for your suggestions.

I tried the icon.c test program and the the problem was the same there: There is no icon in the task bar (just a blank/transparent square).

The icon.c test program is supposed to change the icon every time space bar is pressed. This does not work either, and by that I think we can rule out the workaround that it would work if we just wait a while after program startup, as suggested in issue #1375.

We can also rule out the possibility that I was not setting the alpha channel of the icon pixels properly. I set the all four bytes of each pixel programmatically to 255 (or other values), and furthermore the icon.c test program also sets the alpha channel properly.

I also tested icon.c in Windows 10, and there it works as expected.

Note that for me, it is not critical that `glfwSetWindowIcon()` works. I would be happy if creating a Desktop entry would work instead. My gtkmm sample app also has a blank/transparent square as icon until I make a Desktop entry for it, but creating a similar Desktop entry for my glfw app does not work.

---

<div class="post-metadata">

### Author: ![erith835](https://avatars.discourse-cdn.com/v4/letter/e/e8c25b/32.png) [@erith835](https://discourse.glfw.org/u/erith835)
#### Post date: [February 19, 2021, 9:05am UTC](https://discourse.glfw.org/t/taskbar-icon-in-linux-gnome-3-38-3-ubuntu-20-10/1769/4 "2021-02-19T09:05:37Z")

</div>

I found the problem with the Desktop entry: A desktop entry must have proper StartupWMClass. (The first entry you get if you run your application, and then from a terminal run `xprop WM_CLASS` and click on your application window.)

In my gtkmm test app I did nothing to set the WM\_CLASS which meant that the WM\_CLASS automatically got the same name as the executable, and it seems like in that case you don’t need to set the StartupWMClass in the Desktop entry.

However, in GLFW the WM\_CLASS will be set by the third argument in the `glfwCreateWindow()` which is the Window title, and then the StartupWMClass must be correctly set in the Desktop entry.

---

<div class="post-metadata">

### Author: ![elmindreda](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/elmindreda/32/26_2.png) [@elmindreda](https://discourse.glfw.org/u/elmindreda)
#### Post date: [February 19, 2021, 3:20pm UTC](https://discourse.glfw.org/t/taskbar-icon-in-linux-gnome-3-38-3-ubuntu-20-10/1769/5 "2021-02-19T15:20:48Z")

</div>

You can also specify what the `WM_CLASS` property should be set to with the [GLFW\_X11\_CLASS\_NAME and GLFW\_X11\_INSTANCE\_NAME](https://www.glfw.org/docs/latest/window_guide.html#window_hints_x11) window properties. This removes the dependency on the window title.

---

<div class="post-metadata">

### Author: ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)
#### Post date: [February 19, 2021, 4:38pm UTC](https://discourse.glfw.org/t/taskbar-icon-in-linux-gnome-3-38-3-ubuntu-20-10/1769/6 "2021-02-19T16:38:39Z")

</div>

The fact that `icon.c` didn’t work indicates a potential bug given you are on X11 (for which I believe this should work), so it’s worth filing a Github issue unless @elmindreda thinks otherwise.

---

<div class="post-metadata">

### Author: ![erith835](https://avatars.discourse-cdn.com/v4/letter/e/e8c25b/32.png) [@erith835](https://discourse.glfw.org/u/erith835)
#### Post date: [February 19, 2021, 8:59pm UTC](https://discourse.glfw.org/t/taskbar-icon-in-linux-gnome-3-38-3-ubuntu-20-10/1769/7 "2021-02-19T20:59:05Z")

</div>

Thanks elmindreda,

I can confirm that by running `glfwWindowHintString(GLFW_X11_CLASS_NAME, "icon");` before `glfwCreateWindow()` I can set the WM\_CLASS name to be “icon” which is then different from the window title, and by writing `StartupWMClass=icon` in the desktop entry I can set the icon.

But I was wrong in my assumption that I could leave out the `StartupWMClass` key from the desktop entry file as long as the WM\_CLASS is the same as the executable name. There must be some other mechanism that makes that work for the gtkmm app.

The `glfwSetWindowIcon()` still does not work for me. However, I am happy with the desktop entry solution and besides I don’t know how to file a bug report, so I will not do that unless you insist.

Thanks again for your help.
