wslg icon indicating copy to clipboard operation
wslg copied to clipboard

WSL some icons in taskbar for linux applications are defaulting to Tux (when set_app_id doesn't match with .desktop file)

Open castorfou opened this issue 3 years ago • 13 comments

this is more a question than an issue.

With wsl from store, it is now easy to install and launch linux app within WSL. Usiong ubuntu-22.04, some apps have their own icons in Windows Taskbar such as firefox, gimp. And some don't and default to Tux. (nautilus, sublime-text)

Those apps can come from apt or snap. There is no incidence on these icons. I have opened the .desktop files under /usr/share/applications to give a look to icon entry. Don't see anything obvious.

How can I get proper icon for nautilus, gnome-terminal, etc?

image

wsl --version Version WSL : 1.0.3.0 Version du noyau : 5.15.79.1 Version WSLg : 1.0.47 Version MSRDC : 1.2.3575 Version direct3D : 1.606.4 Version de DXCore : 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp version Windows : 10.0.19044.2364

castorfou avatar Jan 04 '23 08:01 castorfou

@castorfou, thanks for reporting the issue. Currently WSLg can't show some Wayland applications points SVG format bitmap as icon, such as nautilus and many of gnome applications, there is existing issue opened at https://github.com/microsoft/wslg/issues/70, but for Sublime-text, at my end, does show correct icon, as below, the screen capture shows two icons for nautilus and sublime-text. While nautilus shows default tux icon, sublime-text shows its own application's icon. How do you install sublime-text? thanks!

image

hideyukn88 avatar Jan 10 '23 18:01 hideyukn88

I have installed sublime-text with snap.

castorfou avatar Jan 10 '23 19:01 castorfou

@castorfou, thanks. I did install by apt-get. But when installed by snap, icon is placed under snap folder rather than /usr/share/icons, thus icon needs to be located from .desktop file, and WSLg relys on the application to set their desktop file name in set_app_id protocol, as documented as the best practice in the Wayland document, https://wayland.app/protocols/xdg-shell#xdg_toplevel:request:set_app_id. But sublime-text doesn't follow that, thus WSLg is not able to look up .desktop (then icon file), thus default is used. I will look into how other distro who is using Wayland does. Thanks!

hideyukn88 avatar Jan 10 '23 21:01 hideyukn88

thank you @hideyukn88

is there a (easy) workaround to modify applications such as sublime-text not following wayland policy?

castorfou avatar Jan 19 '23 08:01 castorfou

@castorfou, for sublime-text, you can rename /var/lib/snapd/desktop/applications/sublime-text_subl.desktop to /var/lib/snapd/desktop/applications/sublime_text.desktop. Since the application reports "sublime_text" as their app_id, just rename its .desktop file to same as it's app_id, thanks!

hideyukn88 avatar Jan 21 '23 00:01 hideyukn88

@hideyukn88, note to self, the most of snap allocation set desktop file path in BAMF_DESKTOP_FILE_HINT, thus if there is a way to access running process's environment variables from our rdprail-shell, the shell can look up desktop file even the application doesn't set exactly same app_id as desktop file name.

hideyukn88 avatar Jan 21 '23 00:01 hideyukn88

@castorfou, for sublime-text, you can rename /var/lib/snapd/desktop/applications/sublime-text_subl.desktop to /var/lib/snapd/desktop/applications/sublime_text.desktop. Since the application reports "sublime_text" as their app_id, just rename its .desktop file to same as it's app_id, thanks!

Thank you that worked perfectly. I have not followed strictly this process though.

cd /var/lib/snapd/desktop/applications
sudo ln -s sublime-text_subl.desktop  sublime_text.desktop
cd ~/bin
touch sublime_text
chmod +x sublime_text
tee sublime_text << EOF
#!/bin/bash
env BAMF_DESKTOP_FILE_HINT=/var/lib/snapd/desktop/applications/sublime-text_subl.desktop /snap/bin/sublime-text.subl --launch-or-new-window
EOF

I tried to do the same with gnome applications such as gedit There is a gedit_gedit.desktop in /var/lib/snapd/desktop/applications , but creating a link gedit.desktop didn't help with the icon. Icon entry for gedit is Icon=/snap/gedit/664/meta/gui/org.gnome.gedit.svg

castorfou avatar Jan 23 '23 08:01 castorfou

I have just realised that launching gnome apps preceded with dbus-launch will give me directly icons.

dbus-launch nautilus&
dbus-launch gnome-terminal&

image

Decoration are not exactly the same though - biggest window is launched without dbus-launch (and tux icon), smallest with dbus-launch (and nautilus icon)

image

castorfou avatar Jan 25 '23 08:01 castorfou

This is fixed with WSLg 1.0.51

castorfou avatar Apr 04 '23 11:04 castorfou

With wsl v1.2.x, this is broken. (WSL1.2.5 at least but happened with previous version as well) Even if WSLg version stays the same (1.0.51)

castorfou avatar Apr 21 '23 05:04 castorfou

@castorfou, for sublime-text, you can rename /var/lib/snapd/desktop/applications/sublime-text_subl.desktop to /var/lib/snapd/desktop/applications/sublime_text.desktop. Since the application reports "sublime_text" as their app_id, just rename its .desktop file to same as it's app_id, thanks!

The same approach works for Sublime-Merge. Thanks!

My WSL environment is

WSL version: 2.1.5.0 Kernel version: 5.15.146.1-2 WSLg version: 1.0.60 MSRDC version: 1.2.5105 Direct3D version: 1.611.1-81528511 DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp Windows version: 10.0.22631.3447

pandadolphin avatar May 13 '24 04:05 pandadolphin