Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WSLg doesn't pick up the actual icons of Linux desktop apps #614

Open
bbatsov opened this issue Dec 21, 2021 · 19 comments
Open

WSLg doesn't pick up the actual icons of Linux desktop apps #614

bbatsov opened this issue Dec 21, 2021 · 19 comments
Labels
bug Something isn't working start-menu-integration Windows Start Menu integration

Comments

@bbatsov
Copy link

bbatsov commented Dec 21, 2021

Environment

Windows build number: Microsoft Windows [Version 10.0.22000.348]
Your Distribution version:  Ubuntu 20.04
Your WSLg version: 1.0.26

Steps to reproduce

Just run any Linux GUI from the command line or the Windows start menu. All apps have the generic Linux logo icon, which makes them hard to differentiate.

I've installed all apps with apt install.

Expected behavior

I expect each app to display it's all icon (as defined by appname.desktop).

Actual behavior

image

The same generic icon is displayed in the taskbar as well. Interestingly, when I run Emacs as root it displays the right icon.

image

@bbatsov bbatsov added the bug Something isn't working label Dec 21, 2021
@tcfurrer
Copy link

Exact same issue here.
I would like to add that the correct icon shows up separately in the taskbar when the app is running, but the pinned icon and start menu icon is incorrect as already described here.
image

@seven-mile
Copy link

I've been suffering from this issue for months. I guess it relates to the Ubuntu version (mine is also 20.04).

@bbatsov
Copy link
Author

bbatsov commented Jan 2, 2022

I would like to add that the correct icon shows up separately in the taskbar when the app is running, but the pinned icon and start menu icon is incorrect as already described here.

For me the icon was the correct one initially, but after a while all icons from Ubuntu got replaced with the generic one.

@hideyukn88
Copy link
Member

@bbatsov, @tcfurrer, @seven-mile, would you please share /mnt/wslg/weston.log with us?

Basically there is 2 type of icons, a) icons used in Start Menu (or pinned at taskbar), and b) icons at taskbar when applications are running.

Icon a) is specified at .desktop file for that application, for emacs, typically /usr/share/applications/emacs.desktop, which specify as "Icon=emacs", then Icon file will be loaded from /usr/share/icons. And if no icon is specified at .desktop file, then generic Icon will be used.

image

Icon b) is from "_NET_WM_ICON" for X11 application. So if you are not seeing right Icon here, would you check by running xprop ? Please refer below screen capture. And in case application is Wayland native application, same Icon as a) will be used.

image

Thanks!

@seven-mile
Copy link

@hideyukn88 Of course. For (a) icons, on my machine, only gThumb is normal but others are generic icon. Indeed the .desktop configurations correspond with this fact.
nautilus's .desktop file
gThumb's .desktop file

But the (b) icons of all applications including nautilus are not working in the taskbar. I tried xprop wmctrl and xwininfo. But it seemed none of them worked. You may wait for feedback from others.

Attachment:
weston.log.zip

@hideyukn88
Copy link
Member

@seven-mile, thanks for info.

First, for icon a), from your weston.log, the most of your application is using SVG format icon, which is typical in many gnome application, so this is not yet supported. Please see #70 and we are working on it (microsoft/CBL-MarinerCoreUI#95)

[13:13:52.657]     Icon file:/usr/share/icons/hicolor/scalable/apps/org.gnome.Nautilus.svg
[13:13:52.658]     Icon file:/usr/share/icons/hicolor/scalable/apps/org.gnome.gedit.svg
[13:13:52.659]     Icon file:/usr/share/icons/hicolor/scalable/apps/org.gnome.Evince.svg

For icon b), if those gnome application is running as Wayland native mode, then without SVG support, it won't be able to obtain Icon for taskbar. You can try running with in X11 mode by "export GDK_BACKEND=x11", then launch your application, please let us know if this helps. Thanks!

@hideyukn88 hideyukn88 added the start-menu-integration Windows Start Menu integration label Jan 5, 2022
@seven-mile
Copy link

@hideyukn88
Yes, "export GDK_BACKEND=x11" works well. Looking forward to SVG support in this year!

@hideyukn88
Copy link
Member

@bbatsov, @tcfurrer, I would be interested in the missing icons for Emacs case, if you are still experiencing this issue, please let me know. Thanks!

@bbatsov
Copy link
Author

bbatsov commented Jan 7, 2022

Sure, I've attached my weston.log.

weston.log

I notice in it things like:

image

And I had to do a screenshot as copying from WSLg doesn't work for me either. :-)

The Emacs desktop file is basically the default one and the icon is where it should be. I'm not sure what I'm supposed to do with xprop, so I'll take at look at this later.

@kharus
Copy link

kharus commented Jan 18, 2022

It looks like weston doesn't look for icons in /usr/local/share/icons/
As a workaround for emacs I edited file
/usr/local/share/applications/emacs.desktop
and changed Icon to emacs29 and copied icon files from emacs checkout to /usr/share/icons

cd $EMACS_CODE/etc/images/icons/hicolor/
for d in *                                                                                                                                                                                                                            
do
sudo cp $d/apps/emacs.png /usr/share/icons/hicolor/$d/apps/emacs29.png
done

Restarted wslg and emacs now has emacs icon in windows.

@seflerZ
Copy link

seflerZ commented Jan 20, 2022

This is because current WSLg doesn't support SVG icons. Though this function code has been added but the corresponding SVG lib can't be found in Mariner (A Microsfoft linux distro) repository. Refer to this to has more details.

@YAmikep
Copy link

YAmikep commented Feb 16, 2023

I am having the same issue and could not resolve it reading the above.
For example, I installed Gitkraken:

wget https://release.gitkraken.com/linux/gitkraken-amd64.deb
sudo apt install ./gitkraken-amd64.deb

Then I launch it:

gitkraken

I see the generic icon.

Here are the logs:

❯ cat /mnt/wslg/weston.log

[13:44:37.885] set_position_from_xwayland: XWM 860, 302; geometry 32, 32; view 828, 270
[13:44:37.901] app_list_monitor_thread: loadIconEvent is signalled. GitKraken
[13:44:37.901] app_list_monitor_thread: entry (nil), image (nil)
[13:44:37.937] Client: ClientGetAppidReq: pid:9707 appId:GitKraken
[13:44:40.489] set_position_from_xwayland: XWM 334, 140; geometry 32, 32; view 302, 108
[13:44:40.548] app_list_monitor_thread: loadIconEvent is signalled. GitKraken
[13:44:40.548] app_list_monitor_thread: entry (nil), image (nil)
[13:44:40.649] Client: ClientGetAppidReq: pid:9707 appId:GitKraken

Any idea how to fix this?

Should I add a /usr/share/applications/GitKraken.desktop icon? What format should the icon be?


ANSWER:
Nevermind, I was able to find the solution.
There was a gitkraken.desktop file, so I renamed it to match the AppId GitKraken.desktop and it works.

That being said, is there a way to change the generic linux icon displayed on top of the icon based on the distro?
When using the same softwares in different distros, it's impossible to know which one is which as they all look the same.

Yzs8B5Jwxp

@YAmikep
Copy link

YAmikep commented Feb 16, 2023

Another use case is when using an AppImage.
In that case, there is no entry in /usr/share/applications/ so it's not a mismatch of AppId.
Any workaround to this?

Thanks

@Andrew-J-Larson
Copy link

Hey guys, at least for me using Ubuntu, running sudo update-icon-caches /usr/share/icons/* seems to fix the icons for me.

@andnig
Copy link

andnig commented Dec 31, 2023

EDIT: For reasons I can't comprehend, the taskbar shows the correct window just as of today. 3 windows restarts (not weston, the full OS) were in between but nothing else was changed. So my below comment is not valid anymore. Quick recap what I did and what works now:

  • Create a file /usr/share/applications/kitty.desktop (with Icon=kitty)
  • Put an appropriately sized 'kitty.png' file in all folders /usr/share/icons/hicolor/$size/apps/ (with size being 128x128, 16x16, 256x256, 32x32, 512x512, 64x64)

EDIT2: Ok there seems to be an icon cache in windows, didn't know that. So, after following the steps above, make sure to refresh the icon cache. Follow the second answer (user Omoikane1122) in this MS answer

------------ original comment -----------------

I have a similar issue, but none of the workarounds helped so far.
All the icons are correctly set in the start menu, however not in the task bar.
image

Task bar:
image

WSL version: 2.0.14.0
WSLg version: 1.0.59

For eg. for kitty, my desktop file is at /usr/share/applications/kitty.desktop, Icon is set to 'kitty' and there is an appropriately sized 'kitty.png' file in folders /usr/share/icons/hicolor/$size/apps/ (with size being 128x128, 16x16, 256x256, 32x32, 512x512, 64x64)

Is there a chance to get the icons also working on the task bar? Where do we need to put the icons so that they are used in the taskbar?

@lxg208
Copy link

lxg208 commented Jan 3, 2024

This problem has puzzled me for a while and I think I found a solution. The cause is the missing .desktop file. On a new machine I installed Ubuntu 23.10. I compiled emacs from the source and it suffers the same issue. Then I created the missing .desktop file and I have the emacs icon. Back to wsl, I created the same desktop file and it worked as well. Following is my /usr/share/applications/emacs.desktop file, notice the location of emacs and icon file:

[Desktop Entry]
Version=1.0
Name=Emacs (GUI)
GenericName=Text Editor
Comment=GNU Emacs is an extensible, customizable text editor - and more
MimeType=text/english;text/plain;text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-chdr;text/x-csrc;text/x-java;text/x-moc;text/x-pascal;text/x-tcl;text/x-tex;application/x-shellscript;text/x-c;text/x-c++;
TryExec=/home/myuser/local/emacs/bin/emacs
Exec=/home/myuser/local/emacs/bin/emacs %F
Icon=/home/myuser/local/emacs/share/icons/hicolor/scalable/apps/emacs.svg
Type=Application
Terminal=false
Categories=Utility;Development;TextEditor;
StartupWMClass=Emacs
Keywords=Text;Editor;

@terlar
Copy link

terlar commented Jan 3, 2024

Thank you very much @andnig, following the cache refresh tip from that MS answer I finally got the icons to work for the task bar as well.

@antonio-petricca
Copy link

I have the same issue, and none of the above solutions worked for me.

@JotaRata
Copy link

JotaRata commented Sep 8, 2024

I have the same issue and so far nothing has worked for me but I noticed that the correct icons are displayed in the taskbar when running the app with sudo.

imagen

Running the same app without using sudo makes the taskbar to show the default icon.

EDIT: Now I realize this happens because GNOME apps are using X11 when launched with root privileges. SO I assume the issue occuurs when in Wayland mode (the default).
I also exported every GNOME icon as a *.png image in their respective folders and it doesn't work, even though they appear as loaded in the weston.log file.
imagen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working start-menu-integration Windows Start Menu integration
Projects
None yet
Development

No branches or pull requests