nuclear icon indicating copy to clipboard operation
nuclear copied to clipboard

System media control (MPRIS) not working when using the Flatpak version

Open sith-on-mars opened this issue 2 years ago • 7 comments
trafficstars

Platform:: OpenSUSE MicroOS Gnome

Nuclear version:: fd06a3

Description of the issue:: MPRIS doesn't work when using the Flatpak version, despite the fact that it seems to work with standard package version, according to issue 1123. I think there are a lot of Flatpak apps that support MPRIS, it would be super if the developers could implement this.

sith-on-mars avatar Mar 25 '23 03:03 sith-on-mars

Hi, MPRIS works with most of the other packages. I never cared to fix it in flatpak because there's already a lot of different installation options and flatpak makes many things that should be easy a huge pain. But if anyone knows how to do it, I'll gladly merge a fix.

nukeop avatar Mar 25 '23 23:03 nukeop

@nukeop TL;DR: I think you need "--talk-name=org.mpris.MediaPlayer2.nuclear" in org.js.nuclear.Nuclear.json. But I can't actually test it because all playback in Nuclear is currently broken for me, so I'll hold off on submitting a PR.

Also, while you're there, it might be worth it to try "--talk-name=org.freedesktop.Notifications" and/or "--talk-name=org.kde.StatusNotifierWatcher" to see if that's needed to have a system tray icon.


Flatpak makes many things that should be easy a huge pain, if you don't know how to do them, which obviously most of us don't (Because why would we? It was working fine before). Idk. I think they really need better docs or examples or something.

I assume it's an issue of exposing the right DBUS channel.

For reference, this is what I had to do in my own application to get system tray icon support (not MPRIS— Reminds me I should probably do that, actually):

    "finish-args": [
        "--talk-name=org.freedesktop.Notifications",
        "--talk-name=org.kde.StatusNotifierWatcher"
    ]

IIRC I also needed to add a similar override for Nuclear to get it to show in the system tray.

I think this is the relevant spec for MPRIS:

https://specifications.freedesktop.org/mpris-spec/latest/

IIRC, By default in Flatpak "an app can only own [and access] its own name on the bus".

So I believe for Nuclear, that would be org.js.nuclear.Nuclear:

https://github.com/nukeop/nuclear/blob/f9effe4c5d39935449a9c58c7a3d26d682495a2b/flatpak/org.js.nuclear.Nuclear.json#L2

(IIRC They also allow hyphenated qualifiers after the end of the full app ID, or something like that.)

For MPRIS, I think something like:

"--talk-name=org.mpris.MediaPlayer2"

AND/OR

"--talk-name=org.mpris.MediaPlayer2.*"

AND/OR

"--talk-name=org.mpris.MediaPlayer2.<NameOfWhateverNuclearRegistersItselfAs>"

…Should do it.

I would like to test these for you to figure out exactly which it is, but unfortunately, both online and local playback in Nuclear are currently broken for me (#1438, #1439). It may also be --system-talk-name, rather than --talk-name.

…However, in the course of summarizing this, I accidentally discovered that I can temporarily add an override to enable all busses, and then inspect which one is active:

image

It appears that org.js.nuclear.Nuclear.json will require "--talk-name=org.mpris.MediaPlayer2.nuclear". But maybe try the other options, or look at the spec more carefully than I skimmed it, if that doesn't work.

will-ca avatar Apr 07 '23 21:04 will-ca

Adding org.mpris.MediaPlayer2.nuclear worked on my system now system media controls are working flawlessly. Hopefully nukeop or someone else can merge this in with the flatpak by default. If anyone wants to fix the issue you can use flatseal and under the "Owns" section under the "Session Bus" section put org.mpris.MediaPlayer2.nuclear and media controls should work! If you install Freetube you can see that they use this exact solution. Nice find will-ca thanks for the fix. Screenshot from 2023-09-17 20-48-04 Aforementioned freetube is down below this is an unchanged install. Screenshot from 2023-09-17 20-50-30

BinaryGenius avatar Sep 18 '23 00:09 BinaryGenius

Hi, MPRIS works with most of the other packages. I never cared to fix it in flatpak because there's already a lot of different installation options and flatpak makes many things that should be easy a huge pain. But if anyone knows how to do it, I'll gladly merge a fix.

I don't think it's too hard but do I think it has a learning curve? Absolutely. But then again I'm not a developer. I very much appreciate the hard work you've put into the project but I think flatpaks should take your top priority. They offer a form of sandboxing that is basically unheard of among linux applications, the installs are really small and easily manageable, and flatpaks are of course distro agnostic. Considering you use electron I'm sure you are well aware of the benefits distro agnostic packing schemes bring to the table. More people will have access to your app too so why not use flatpak. I think at the very least we could remove appimages. If it was up to me I'd have a .exe .dmg and a flatpak but I'd like to know what you think.

BinaryGenius avatar Sep 18 '23 01:09 BinaryGenius

The Flatpak config is here: https://github.com/flathub/org.js.nuclear.Nuclear

Do you think your solution can be permanently added to it?

nukeop avatar Sep 18 '23 13:09 nukeop

BTW, check out the release statistics: https://tooomm.github.io/github-release-stats/?username=nukeop&repository=nuclear

Appimages are one of the most popular binaries. I don't track installation or downloads elsewhere so I don't have any up to date metrics but Appimages are the most painless distro-agnostic way to install Nuclear, I certainly don't want to discontinue them.

nukeop avatar Sep 18 '23 13:09 nukeop

BTW, check out the release statistics: https://tooomm.github.io/github-release-stats/?username=nukeop&repository=nuclear

Appimages are one of the most popular binaries. I don't track installation or downloads elsewhere so I don't have any up to date metrics but Appimages are the most painless distro-agnostic way to install Nuclear, I certainly don't want to discontinue them.

Well I was just saying in terms of scalability maybe if all effort was concentrated on Flatpaks that would be beneficial. Surely the Appimage users would be able to make the switch and we wouldn't lose too many users. People who use Linux are usually technically inclined anyways, not that Flatpaks are that hard to get up and running. I actually use a Flatpak called "Gear Lever" just to get Appimages as an icon on my desktop for Gnome so I would imagine using Appimages are more difficult for the end user. I know that Snaps are definitely redundant since we have Flatpaks the only use case I know of for Snaps are for sandboxing for VPN applications like IVPN, but Nuclear is just a music player. We could just keep everything the same and not remove any installs but I think using KISS principles would speed up development and shrink the number of bugs you guys have to fix as this app grows and develops.

The Flatpak config is here: https://github.com/flathub/org.js.nuclear.Nuclear

Do you think your solution can be permanently added to it?

I'll try but I have limited experience with this. I'm assuming I can use Freetube's flatpak config as a reference since they used the same solution. If I find a fix I'll try and make a PR.

BinaryGenius avatar Sep 18 '23 17:09 BinaryGenius

I merged the above PR.

nukeop avatar Feb 13 '24 10:02 nukeop