Icon in panel for yad script

I use often yad in my scripts to show a window. Even set an icon in yad command, the icon of the yad’window in the panel is not the icon I set in the command. Why ? How to fix ?
yad --title="Backup" --text="Backup completed successfully." --button=OK --window-icon='dialog-information'

Make a desktop application for it. Goes into ~/.local/share/applications.

This doesn’t work for me (Debian 14 KDE Plasma 6.6.4 Wayland).
For instance, I have a Python script providing a GUI for the speed test cli by Ookla, but using a desktop file like the one below displays the icon specified there in Dolphin file preview only. I see only “W” on the task bar when it’s launched. Well, actually the icon specified in desktop file is also displayed for a couple of seconds first, and then it disappears.

[Desktop Entry]
Type=Application
Version=1.0
Name=Internet Speedtest
GenericName=Speedtest
Comment=Measure Internet download and upload speeds
Categories=Network;
Exec=$HOME/.local/bin/speedtest-gui.py
Icon=speedtest
StartupNotify=true
StartupWMClass=speedtest-gui
Terminal=false
X-KDE-SubstituteUID=false

Try another icon or a more path specified one. That is..the command (exec) works from a terminal? And by W you mean this?

No problem with the exec command working in any form.
Using a system icon or specifying full path doesn’t make any difference.

That “W” kinda reminds me of a wayland bug. Something about a gtk not adapted to wayland.

There have been some on discuss, the likes of: https://discuss.kde.org/t/bug-generic-wayland-icon-for-many-applications/2468

Guess trying it in X11 couldn’t harm. In either case, the OP wasn’t really clear about his problem. If he’s on X, the desktop app should work.

I also have shell scripts using YAD windows with the same problem. Perhaps both Wayland and YAD need some more work to do in this regard. I even see KDialog windows displayed with a symbolic icon (play, run or something) while the specified icon is displayed on the window titlebar, which I guess means there is a Wayland bug involved here.

I honestly don’t know but from a few of these “W” related icons, they point to this gtk-wayland thing. I’m probably far from the best to give you an answer and some Wayland guys would/could provide you with an answer. I’ve no idea if the OP’s Yad problem is related in any way. Didn’t provide much info. Anywho…bedtime on this geo location. Night man.

I’m not completely sure but what I did for neovim could be relevant / helpful? Iirc then you can’t control things like window icons or the position of the window itself because it’s controlled by the compositor in this case Wayland which ignores those hints. I used a .desktop workaround in my case which should work for you too.

My post:

I’m essentially targeting the window by its title with a KWin Script then setting its “Desktop file” option to neovim you could try the same with your yad window since the title arg is respected by Wayland

More info:

That’s the icon I see in panel for a yad’window with icon set.

Try my KWin Rule method, it seems to have worked for @Sadi

In order to help futur reader, can you write here the solution for my ask please

Sure!

  1. You launch yad with your needed args:
yad --title="Backup" --text="Backup completed successfully." --button=OK 

Notice how I removed --window-icon='dialog-information', that hint is ignored under Wayland.

  1. Either press

Alt + F3 then M, W

OR

Right Click on the yad dialog titlebar then go Special Actions > Configure Special Window Settings...

  1. Write a name/description for the rule, then for the Window title option either write the whole title or use a regular expression (in this case it’s Backup, and for the regex you could use something like ^Backup)

  2. Press on + Add property..., search for Desktop file name, select it, change the apply mode to Force (so KWin always overrides the icon regardless of what the app reports), and write the name of your .desktop file.

e.g. if the filename is nvim.desktop then write nvim. KWin searches for a matching .desktop file in the standard XDG data directories (/usr/share/applications/, ~/.local/share/applications/, etc.)

  1. If you don’t have an existing .desktop file that uses the icon you want, you can create one pointing to the icon path you want:
cat > ~/.local/share/applications/myapp-custom.desktop << 'EOF'
[Desktop Entry]
Type=Application
Name=My App
Icon=/path/to/your/icon.png
NoDisplay=true
EOF

Then in the previous step instead of putting nvim as Desktop file name you’d put myapp-custom.

Yep, I confirm your trick works fine, bravo !