Run Flatpak apps by search filter or through fuzzy finder menu

I wrote a simple script in order to help someone in a recent reply from me, to make running Flatpak applications from terminal easier. After that I worked a little bit on it further and now ended up with 2 completely different approaches.

  1. flatrun: Run an app by a matching search filter. If multiple matches, then print all matching app ids instead.
  2. flatapp: Show list of installed apps in an interactive menu. Plus show a description of the app in a preview window. Run the selected application. Requires fzf.
  3. flatsearch: Show search results from repository in an interactive menu. A selected entry will be installed or uninstalled if it exists already (with confirmation from flatpak). Requires fzf.

<span style="font-style:italic;color:#969896;"># Show all matching apps
</span><span style="color:#323232;">$ flatrun F
</span><span style="color:#323232;">com.github.tchx84.Flatseal
</span><span style="color:#323232;">io.freetubeapp.FreeTube
</span><span style="color:#323232;">
</span><span style="font-style:italic;color:#969896;"># Run io.freetubeapp.FreeTube
</span><span style="color:#323232;">$ flatrun freetube
</span><span style="color:#323232;">
</span><span style="font-style:italic;color:#969896;"># Show help for com.obsproject.Studio
</span><span style="color:#323232;">$ flatrun obs --help
</span>

or flatapp: (requires fzf)

https://beehaw.org/pictrs/image/b101061a-da8e-4842-893a-d0dda9e4148c.webp

and new flatsearch youtube (requires fzf)

https://beehaw.org/pictrs/image/f33e2387-6944-4409-90f9-2ec6bbf41d66.webp

Dirk,
@Dirk@lemmy.ml avatar

That’s simple bash completion but with extra steps :)

thingsiplay,

Not really, because the search term can match anywhere in the name. Also it searches in executable name (app id) and the app name, a descriptive text. So its more than a Bash completion would be.

mwguy,

Can we just have flatpak apps added to the system path by default? Like have a directory /usr/local/flatpak/bin and have links to all the executable show up there. Then users can choose to add that to their path if they wish.

thingsiplay,

We have that already: $ ls “/var/lib/flatpak/exports/bin/”

mwguy,

Well now I feel silly. Brb changing my default path.

thingsiplay,

No need to feel silly. If you didn’t ask, you wouldn’t learn about it. I learned about it yesterday in the post where I initially gave the first version of the script. It’s a documentation issue I would say, in some way. Such an important part should have been made clear for every user.

I “insist” you feel not sorry, because I’m in the same boat as you. :D

Dirk,
@Dirk@lemmy.ml avatar

… and this part is before /usr/local/bin making it impossible to override Flatpak bins or desktop files.

thingsiplay, (edited )

One can just move the path to another place in the $PATH. Not really impossible. Not an elegant solution, just proof of concept:


<span style="font-weight:bold;color:#a71d5d;">export </span><span style="color:#323232;">PATH</span><span style="font-weight:bold;color:#a71d5d;">=</span><span style="color:#183691;">"$(</span><span style="color:#62a35c;">echo </span><span style="color:#183691;">"${</span><span style="color:#323232;">PATH</span><span style="color:#183691;">}" </span><span style="font-weight:bold;color:#a71d5d;">| </span><span style="color:#323232;">sed </span><span style="color:#183691;">'s+:/var/lib/flatpak/exports/bin++'):/var/lib/flatpak/exports/bin"
</span>

Edit:

Or if it makes you uncomfortable to change the placement of this folder in the $PATH, instead you can just add a new directory solely for this purpose. In example add “/home/yourname/.local/flatpak/bin” (or whatever else you like) and put it in front of the flatpak exports directory.

barbara,

those commands are gold! Thank you for sharing! Saved them. They work flawlessly so far.

If flatpak search would work with fzf, it would be easier to use and faster than GNOME software

edit:

I added echo “${app}” to flatapp in order to print the app in terminal to have a visual response which app will run. (some apps take some seconds to open on my slow machine)

thingsiplay, (edited )

I thought about additional echo for confirmation too! I will add it too (give me 2 minutes), but it will output to stderr, so it’s not part of regular output.

Edit: So I added


<span style="color:#62a35c;">echo </span><span style="color:#183691;">"flatpak run" "${</span><span style="color:#323232;">app</span><span style="color:#183691;">}" "${</span><span style="color:#323232;">@</span><span style="color:#183691;">}" </span><span style="font-weight:bold;color:#a71d5d;">>&</span><span style="color:#323232;">amp</span><span style="font-weight:bold;color:#a71d5d;">;</span><span style="color:#323232;">2
</span>

, which as said will output to stderr instead. And I also decided to add flatpak run and the arguments too, but that’s just an “aesthetic” choice.

thingsiplay,

Hey, I just created a search with fzf menu for install or uninstall app. It’s not pretty, because its a bit unorganized looking and I could not find a good and easy way to solve this. But it seems to be working so far.

flatsearch

barbara,

That is awesome as well. Incredible what you can do with just a few lines of code.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • linux@lemmy.ml
  • rosin
  • ethstaker
  • tacticalgear
  • osvaldo12
  • mdbf
  • DreamBathrooms
  • thenastyranch
  • magazineikmin
  • Youngstown
  • everett
  • InstantRegret
  • slotface
  • ngwrru68w68
  • kavyap
  • JUstTest
  • GTA5RPClips
  • Leos
  • modclub
  • cisconetworking
  • Durango
  • khanakhh
  • cubers
  • normalnudes
  • anitta
  • tester
  • megavids
  • provamag3
  • lostlight
  • All magazines