Update to My Flatpak CLI Shortcut Proof of Concept

This morning, I finally got around to rewriting my update_nvidia helper to unbreak the whole “defer driver updates until reboot to keep the kernel module and libGL in sync” thing I have going and, this afternoon, while working on something else, I realize that anything running in Flatpak was working all along because the Flatpak devs did too good a job of detecting and supplying matching in-runtime libraries for video drivers.

Why is this relevant? Well, because I realized it while fixing something else that had been bugging me: The papercuts in my script for generating flatpak CLI launcher wrappers.

For those who missed my initial announcement, it’s a script you run after installing something through Flatpak and it generates a wrapper so you can type mpv instead of flatpak run io.mpv.Mpv in a terminal window, and it’ll even handle --file-forwarding for you so you get an experience comparable to what the XDG File Chooser portal gives you with Open/Save dialogs.

So, what did I improve? Well, here’s the features list now:

  1. Run it with no arguments and it’ll set up or update a ~/.local/bin/flatpak you can add to your PATH. (not new)
  2. Add things to the CMD_REMAPPINGS list (which comes with entries like [scummvm_wrapper]='scummvm' and ["com.github.tchx84.Flatseal"]='flatseal' pre-populated) to fix stuff it couldn’t quite get right. (NEW)
  3. Add things to the EXTRA_CMDS list (which comes with ["com.github.AmatCoder.mednaffe"]='mednafen' and ["org.atheme.audacious"]='audtool' pre-populated) and you can optionally expose a second command from inside each Flatpak. (NEW)
  4. Unsets LD_PRELOAD before launching the Flatpak application to silence spurious “Can’t find libgtk3-nocsd.so.0 in the Flatpak runtime” errors. (not new)
  5. If any arguments are valid relative paths, make them absolute to fix an annoying bug with how --file-forwarding behaves without breaking non-path arguments. (NEW)

I did have to switch from dash-compatible shell script to bash script to take advantage of proper array support, but, from what I remember, the Linux Standard Base required that /bin/bash exist, so that shouldn’t be too big a hardship.

It still doesn’t solve the problem of Flatpak’s not coming with man pages, but there’s not a lot I can do when the files just aren’t included. Aside from that, I’m very impressed at how polished this feels when I’m hacking around the Flatpak developers’ putting their foot down and declaring comfortable command-line operation to be out of scope.

Enjoy. 🙂

CC BY-SA 4.0 Update to My Flatpak CLI Shortcut Proof of Concept by Stephan Sokolow is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

This entry was posted in Geek Stuff. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

By submitting a comment here you grant this site a perpetual license to reproduce your words and name/web site in attribution under the same terms as the associated post.

All comments are moderated. If your comment is generic enough to apply to any post, it will be assumed to be spam. Borderline comments will have their URL field erased before being approved.