Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spotify Task Manager - KDE #58

Open
DarkArc opened this issue Sep 27, 2018 · 24 comments
Open

Spotify Task Manager - KDE #58

DarkArc opened this issue Sep 27, 2018 · 24 comments

Comments

@DarkArc
Copy link

DarkArc commented Sep 27, 2018

KDE will normally provide right click options for apps with audio playback in their taskbar entry. This does not happen with the Flatpak version.

This functionality has been available since Plasma 5.12
https://www.kde.org/announcements/plasma-5.12.0.php (See the "Task Manager Improvement" section)

@DarkArc DarkArc changed the title Spotify Task Bar - KDE Spotify Task Manager - KDE Sep 27, 2018
@DarkArc DarkArc closed this as completed Sep 27, 2018
@DarkArc DarkArc reopened this Sep 27, 2018
@TingPing
Copy link
Member

Does a non-flatpak'd Spotify work?

Do you have any more details how this is implemented?

@DarkArc
Copy link
Author

DarkArc commented Sep 27, 2018

Yes, it works using the normal deb on both Ubuntu 16.04 and 18.04 (this is what I've tested anyways). It uses MPRIS2.

Here's the commit that introduced basic support:
https://cgit.kde.org/plasma-desktop.git/commit/?h=v5.12.0&id=d3e7a1985b7fd769514e1cbd8cf54dafa26863ae

Additional commits can be found in this search result set:
https://cgit.kde.org/plasma-desktop.git/log/?h=v5.12.0&qt=grep&q=task

EDIT: Also, thanks for the speedy reply :)

@TingPing
Copy link
Member

MPRIS does work here, but it is very janky and will disappear while running sometimes.

There has to be another detail that is different.

@TingPing
Copy link
Member

TingPing commented Sep 27, 2018

It is just getting the wrong name:

+           // MPRIS spec explicitly mentions that "DesktopEntry" is with .desktop extension trimmed
+            var desktopFileName = launcherUrl.toString().split('/').pop().replace(".desktop", "")

We can't easily fix that, sadly.

We could implement a proxy but its a bit of work.

@DarkArc
Copy link
Author

DarkArc commented Sep 28, 2018

Hm... So are you thinking this would be an issue for any flatpak'd app? I wonder if this would be better patched at a flatpak/kde level depending on what's going on?

@TingPing
Copy link
Member

TingPing commented Oct 5, 2018

It is an issue for all apps that renamed their desktop file. We can try to get upstreams to change their mpris names too for Foss apps. The problem here is just that Spotify is proprietary and we are doing the renaming. KDE could work around this with a Flatpak specific check but I don't know if they would appreciate that hack.

@dennisoehme

This comment has been minimized.

@TingPing

This comment has been minimized.

@JasonLG1979
Copy link
Contributor

We could implement a proxy but its a bit of work.

What would that take? Really the only thing we would override is the desktop id that it's sending. This is also the reason you can't raise the flatpak'd Spotify in the default GNOME shell MPRIS controls.

@TingPing
Copy link
Member

What would that take? Really the only thing we would override is the desktop id that it's sending. This is also the reason you can't raise the flatpak'd Spotify in the default GNOME shell MPRIS controls.

Not trivial I believe. Here is an example of a dbus proxy: https://github.com/flatpak/xdg-dbus-proxy/blob/master/flatpak-proxy.c

It does a lot more than we need though so maybe this could be done in a 100 lines of Python or something but I've not looked into it.

@JasonLG1979
Copy link
Contributor

Could we and/or wrap the hole application in a Gio.Application? That might solve a lot of paper cuts.

@TingPing
Copy link
Member

I'm not sure what that changes, but either way you have to proxy the data to the real mpris service.

@JasonLG1979
Copy link
Contributor

I'm not sure what that changes, but either way you have to proxy the data to the real mpris service.

Maybe issues with opening multiple instances, not having the correct icon in the pulseaudio volume control. And possibly make it so it will actually open and play the spotify mime-types.

@JasonLG1979
Copy link
Contributor

It's probably more work then it's worth but I'm a gluten for punishment.

@TingPing
Copy link
Member

We have no way of focusing the existing instance (well X11 grossness) or passing URLs to the existing instance. Upstream needs to fix that.

@JasonLG1979
Copy link
Contributor

JasonLG1979 commented Oct 30, 2019

We have no way of focusing the existing instance (well X11 grossness)

The activate method would handle that for us. Basically it creates a new instance if there isn't one already or focuses the app if an instance exists.

in do_activate() You would basically check to see if there's a window already just like Pithos.

passing URLs to the existing instance.

Spotify's OpenUri MPRIS method actually does work. It's just a matter of wiring it up so that a passed uri is feed to that.

@JasonLG1979
Copy link
Contributor

The basic idea is to make a filtered Dbus activatable wrapper for Spotify.

@JasonLG1979
Copy link
Contributor

It would also get rid of that janky script to set the widow border dark.

@JasonLG1979
Copy link
Contributor

On the subject of the icon not showing up in the pulseaudio volume controls wouldn't that be a matter of simply adding something like this to finish-args in com.spotify.Client.json:

    "--env=PULSE_PROP_application.name="Spotify"",
    "--env=PULSE_PROP_application.id="com.spotify.Client"",
    "--env=PULSE_PROP_application.icon_name="com.spotify.Client"",
    "--env=PULSE_PROP_media.role="music""

@JasonLG1979
Copy link
Contributor

Scratch that:
--env=PULSE_PROP_application. anything doesn't work because of the period.

But changing:
/app/extra/bin/spotify --force-device-scale-factor=$SCALE_FACTOR "$@" &

To:
env PULSE_PROP_application.icon_name="com.spotify.Client" /app/extra/bin/spotify --force-device-scale-factor=$SCALE_FACTOR "$@" &

in spotify-bin does work to set the icon correctly in the GNOME sound settings at least.

I'll put in a PR.

@TingPing
Copy link
Member

Spotify's OpenUri MPRIS method actually does work. It's just a matter of wiring it up so that a passed uri is feed to that.

I didn't realize that, ok then this becomes much more doable.

@JasonLG1979
Copy link
Contributor

I didn't realize that, ok then this becomes much more doable.

Yep you can pass this "https://open.spotify.com/track/2NdIe95VMTVifMkiKQUja8" for example to the OpenUri method and it will direct the Spotify UI to Metallica - Crash Course in Brain Surgery but it doesn't start playing it as you would think it would do. In my mind OpenUri should start playing the song if Spotify is already playing. Anyway that works for playlists and albums also.

But if you try the open in desktop link in the Spotify web UI it will start a new instance of Spotify.

@JasonLG1979
Copy link
Contributor

I almost wonder if I couldn't hack together a fully functioning MPRIS implementation TrackList and PlayLists and all using the spotify connect web API?

@JasonLG1979
Copy link
Contributor

I can at least probably fix the lack of volume controls by tying the dbus filter proxy's volume to pulseaudio's volume.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants