sakithb / media-controls

A media indicator for the Gnome shell.
MIT License
236 stars 36 forks source link

Player icon not working properly #47

Closed lorenzobazzana closed 11 months ago

lorenzobazzana commented 2 years ago

Hi, I think there's an issue with some player icons for gnome themes that use the default icon for those players.

For example, the theme "Flat Remix" has a custom icon for Spotify and Rhythmbox and everything works fine, while the theme "Flatery-dark" uses the default icons and they don't show up at all, they're replaced istead by a generic audio icon.

By looking around, I think that the issue is related to the get icon() method at line 862 in player.js: if the value returned does not match exactly an app icon the extension just thinks that there's no icon at all for that app. This means that some default icons are ignored because they have different names (eg. com.spotify.Client or org.gnome.Rhythmbox)

ChrisLauinger77 commented 11 months ago
    get icon() {
        let icon;

        if (this._otherProxy.DesktopEntry) {
            icon = this._otherProxy.DesktopEntry;
        } else {
            icon = this.name.toLowerCase().split(" ");
            icon = icon[icon.length - 1];
        }
        if (!icon.includes(".")) {
            let appsys = Shell.AppSystem.get_default();
            for (let app of appsys.get_running()) {
                if (app.get_name().toLowerCase().includes(icon)) {
                    icon = app.get_id().replace(".desktop", "");
                }
            }
        }
        return icon;
    }

this would be my proposal @sakithb it looks for running apps and finds the icon this import also would need to be added:

import Shell from "gi://Shell";

I worked on it - not realising you also had it in progress :(

sakithb commented 11 months ago
    get icon() {
        let icon;

        if (this._otherProxy.DesktopEntry) {
            icon = this._otherProxy.DesktopEntry;
        } else {
            icon = this.name.toLowerCase().split(" ");
            icon = icon[icon.length - 1];
        }
        if (!icon.includes(".")) {
            let appsys = Shell.AppSystem.get_default();
            for (let app of appsys.get_running()) {
                if (app.get_name().toLowerCase().includes(icon)) {
                    icon = app.get_id().replace(".desktop", "");
                }
            }
        }
        return icon;
    }

this would be my proposal @sakithb it looks for running apps and finds the icon this import also would need to be added:

import Shell from "gi://Shell";

I worked on it - not realising you also had it in progress :(

Thanks, that should work, you can push the changes, I did not really progress on the issue much.

sakithb commented 11 months ago

or I can do it if you don't mind

ChrisLauinger77 commented 11 months ago

main and gnome44 updated