flathub / org.atheme.audacious

https://flathub.org/apps/details/org.atheme.audacious
5 stars 4 forks source link

Support for audtool (command line interface)? #9

Open danieldg opened 3 years ago

danieldg commented 3 years ago

There are two ways that I think are useful to do this:

Adding --own-name=org.atheme.audacious=own would allow an existing audtool binary (or other user of the dbus interface) that is running outside the flatpak to control audacious regardless of where it's running. You can use /var/lib/flatpak/app/org.atheme.audacious/current/active/files/bin/audtool to test outside the flatpak.

I'm not sure if this is easy to to with flatpak, but providing a way to easily invoke audtool from the outside would also be useful. flatpak enter org.atheme.audacious audtool does work, but it's not very discoverable. In particular, a wrapper that also adds the equivalent of --file-forwarding would be useful.

ssokolow commented 2 years ago

From my time poking at the Flatpak documentation to experiment with building something under Flatpak, I'm not sure if it's possible for a Flatpak to export more than one command-line command.

Even if it is, the only automatic/supported way to expose command-line commands is as reverse-DNS filenames under /var/lib/flatpak/exports/bin or ~/.local/share/flatpak/exports/bin, which you're then supposed to add to your PATH.

I had to write my own proof-of-concept script to generate and maintain launcher wrappers named after the commands inside the Flatpaks.

...but thanks for looking up the path I manually have to do something with at ~/bin/audtool to get my scripts working under Flatpak without a wrapper if I'm going that route.

I haven't tested it yet (still getting the paths for my playlists Flatseal'd into place so I don't have to rewrite all the paths), but this is my draft wrapper based on what that proof-of-concept generates:

#!/bin/sh
unset LD_PRELOAD
exec flatpak run --file-forwarding --command=audtool org.atheme.audacious @@u "$@" @@

(I can confirm that the proof-of-concept works for other Flatpaks. I use it every day and, aside from the lack of a MPV manpage and commands like scummvm_wrapper instead of scummvm in some places, it makes the presence of Flatpak invisible. The unsetting of LD_PRELOAD is so I don't get spurious errors about gtk3-nocsd not being available inside the Flatpak runtimes.)

ssokolow commented 2 years ago

OK, I did a bit of testing and that wrapper appears to work perfectly aside from imparting a minor but noticeable delay to my xbindkeys bindings that run through audtool rather than invoking D-Bus directly due to the added process startup overhead.

(I may rewrite them to use dbus-send or qdbus instead.)

No clue if the file forwards will persist forever, but they seem to work across an Audacious quit-and-restart cycle where flatpak ps confirmed that nothing Audacious was running.