end-4 / dots-hyprland

i hate minimalism so...
https://end-4.github.io/dots-hyprland-wiki/en/
GNU General Public License v3.0
4.52k stars 315 forks source link

Dynamically parse icons for "overview" widget #126

Open Gufderald opened 11 months ago

Gufderald commented 11 months ago

So, it would be great to parse substitutions for icon names dynamically; applications folders (/usr/share/applications, ~/.local/share/applications) can be used for that, as .desktop files store correct icon names. Also this probably may be achieved via Applications ags service.

end-4 commented 11 months ago

searching for a desktop entry won't easily make it work, since the window class might be something weird, and currently the application service doesn't have fuzzy search. but modifying the string i think could help... maybe i'll turn those names into kebab-case if there's no icon for the window class

gori-yar4e commented 11 months ago

Hi! It seems to me that in most cases icon name can really be covered by lowercasing class name. Prepared an PR, seems to work good for now.

Gufderald commented 11 months ago

Hi guys! Just actualized my configs from branch - it's better now, but still missing some icons (smth around 50% of my apps). I'll also try solution from @gori-yar4e in the nearest future

Gufderald commented 11 months ago

So, seems that @gori-yar4e's solution works better.

const iconNameMap = new Map()
Applications.list.forEach((app) => {
    iconNameMap.set(app.desktop.split('.desktop')[0].toLowerCase(), app['icon-name'])
})

function substitute(str) {
    const subs = [
        { from: 'Gimp-2.10', to: 'gimp' },
    ];

    for (const { from, to } of subs) {
        if (from === str)
            return to;
    }
    return iconNameMap.get(str.toLowerCase()) || 'image-missing';
}

produces image

and source config produses image (same apps)

Gufderald commented 11 months ago

There is some another trouble with apps installed by snap - only telegram does not require handmade substitution. Going to research it in a near future.

clsty commented 8 months ago

Any progress on this issue? I see Tilix missing its icon on the overview widget currently. The desktop file of Tilix has a line Icon=com.gexperts.Tilix and this icon is displayed normally when running Tilix on xfce4.

yrnmsk commented 8 months ago

I also want to bump on this issue.


On a side note, I was wondering if it is also possible to consider for window's .initialTitle to be passed onto the substitute function responsible for determining icons. As of right now, it only accepts window class as initially proposed by @gori-yar4e (sorry for mention).

Usually works, but there are also some cases that it does not, but it also especially fails to work when the application decides to provide an empty class for its window properties. Spotify, when ran on wayland, is a good example of this. But I also encountered another application that has this bug which I cannot remember right now.

If the other apps with missing icons provide the app name on their initial title on startup then we can maybe use that to compare with the list of substitutions.

Titles may also work but not that always reliable. If you just consider that the longer uptime of the application is, then the higher chance that it has already changed its window title by then.

Compared to the frequent change of window titles, initial titles usually stay the same. If the app is capable of being hidden in tray, then it may change its initial title when opened again to the current window title, which may no longer contain the correct substitution string for icon. But even then, it should mostly work aside from that.

I feel like this is a long shot, but I also feel like this has a good chance as well.