Score:0

How do I change an application's icon in the Plasma task switcher?

in flag

I'm using Ubuntu 22.04 with the KDE Plasma desktop environment. I downloaded the Obsidian personal wiki as an AppImage, and I added a Menu item for it and created a .desktop file in ~/.local/share/applications/.

When creating the Menu item, I added the Obsidian logo as the application's icon. In the menu and in the taskbar, Obsidian shows with this icon. In the Alt+Tab task switcher, however, it shows up as what I assume is a "placeholder" icon of a grey square with a black "X" that has a yellow/orange equatorial ring around it.

If I right-click the application in the Menu and select "Edit Application", the icon selection widget shows the correct icon. The .desktop file has this line to define the icon:

Icon=/home/username/icons/Obsidian.png

I'm certain this line is correct because if I change it to anything else (like Icon=~/icons/Obsidian.png, for instance), then the Menu no longer shows the icon for Obsidian (it just has a blank space instead). For some reason, however, the task switcher isn't picking up the icon from that file.

I'm using the "MediumDefault" task switcher. How do I configure it to use the correct icon file for a given application?

Edit: More

Following @vanadium's answer, I found xprop was the only tool they mentioned that I already had. I used it to find WM_CLASS(STRING) = "obsidian", "obsidian". (To use it, run xprop in the terminal and then click on the window whose info you want).

In ~/.local/share/applications/Obsidian.desktop I added a StartupWMClass line to the end and then tried each of these forms for it in turn:

  • StartupWMClass="obsidian", "obsidian"
  • StartupWMClass="obsidian"
  • StartupWMClass=obsidian

None of them caused the Obsidian icon to replace the placeholder icon in the task switcher after saving the file, however.

Nmath avatar
ng flag
*"has a blank space instead... This suggests the .desktop has the correct Icon line"* - it suggests the opposite! I recommend that you continue to use the absolute path (the one that starts with `/`)
Darien Marks avatar
in flag
@Nmath This is precisely what I mean to say. The `Icon` line as given in the specially-formatted line of my question is clearly the correct one.
Darien Marks avatar
in flag
The problem is that the icon does not appear in the task switcher
Darien Marks avatar
in flag
I edited my question to clarify this point, sorry for the confusion.
Score:1
cn flag

The desktop is not able to connect the desktop launcher with the final process. To correct this, you will need to specify the WMClass of the Obsidian window(s) in the desktop file.

  1. Determine the WMClass of the window using either wmctrl -lx or xprop (works only on Xorg) or by using the Gnome Shell looking glass (hit Alt+F2, type lg then hit Enter and head to the "Windows" tab to see properties of open windows listed).

  2. Specify that WMClass in the desktop launcher by adding a line

    StartupWMClass=window.class.you.found.in.step.1`
    
Darien Marks avatar
in flag
These are some new concepts for me, so thank you for taking the time to explain them. Unfortunately this didn't fix the issue; I've edited my question with details.
vanadium avatar
cn flag
I assume you came to this conclusion after also trying to log out and then back in, or rebooting the computer? If so, then indeed he cause will need to be searched elsewhere.
Darien Marks avatar
in flag
I did not. Since I've noticed other changes to `.desktop` files taking effect immediately, I assumed this one would, too. I'll update as soon as I've had the chance to try logging out. Thanks!
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.