Moon-0xff / gnome-mpris-label

A music related GNOME extension.
GNU General Public License v3.0
50 stars 9 forks source link

Changing source to also change what media keybinds control #104

Open Freeplayg opened 1 month ago

Freeplayg commented 1 month ago

I'm not sure if it is possible? But it would be really nice if changing the source from here could also change what the media keybinds control Screenshot from 2024-06-05 12-16-28 image

Moon-0xff commented 1 month ago

It's possible, but it requires quite a lot of hacking.

It would require a way of communicating the selected source to an outside script of your own.
I've been thinking of exposing the selected player source for this kind of use, but there's no good and simple approach to this.

If you want to make this work as a hack, you could add a line that exposes this.player.identity or this.player.address, probably in this if statement on _refresh:

        if(this.player != prevPlayer)
            this._getStream();

My idea would be to log it:

        if(this.player != prevPlayer) {
            this._getStream();
            log("MprisLabel:SOURCE = " + this.player.identity);
        }

Then capture the log in a bash script with grep, but that's personal preference, you can use python or any scripting language for this.

For sure this is not a great solution, you'll have to patch the code every time the extension updates, you'll log useless data, and you'll have to develop the script.
If that doesn't deter you then go right ahead! I think the only additional information you need is the name and options of the keybinding settings, which you can change with the gsettings command.