Run Flatpak apps by search filter or through fuzzy finder menu (gist.github.com)
from thingsiplay@beehaw.org to linux@lemmy.ml on 11 Apr 2024 06:05
https://beehaw.org/post/13084117

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.
# Show all matching apps
$ flatrun F
com.github.tchx84.Flatseal
io.freetubeapp.FreeTube

# Run io.freetubeapp.FreeTube
$ flatrun freetube

# Show help for com.obsproject.Studio
$ flatrun obs --help

or flatapp: (requires fzf)

and new flatsearch youtube (requires fzf)

#linux

threaded - newest

barbara@lemmy.ml on 11 Apr 2024 06:41 next collapse

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@beehaw.org on 11 Apr 2024 06:48 next collapse

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

echo "flatpak run" "${app}" "${@}" >&2

, 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@beehaw.org on 11 Apr 2024 12:19 collapse

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@lemmy.ml on 12 Apr 2024 06:54 collapse

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

mwguy@infosec.pub on 11 Apr 2024 06:49 next collapse

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@beehaw.org on 11 Apr 2024 06:59 collapse

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

Dirk@lemmy.ml on 11 Apr 2024 10:03 next collapse

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

thingsiplay@beehaw.org on 11 Apr 2024 10:28 collapse

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

export PATH="$(echo "${PATH}" | sed 's+:/var/lib/flatpak/exports/bin++'):/var/lib/flatpak/exports/bin"

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.

boredsquirrel@slrpnk.net on 04 Jun 2024 09:50 collapse

Or use ~/.local/bin/

Didnt know about the preferences. These only depend on the order of placement in PATH?

Or do they get by directory hierarchy, i.e. HOME can always override the System.

Unix stuff is so simple sometimes

thingsiplay@beehaw.org on 04 Jun 2024 19:17 collapse

No, the order of the directories in the $PATH is important. If you run command by name like grep, then the system will lookup in $PATH beginning from first directory. If its not in the first entry, then it falls back to next entry. If you have a command with same name multiple times in different directories, then you display all found paths with which -a grep in example; the first entry is what is used when running the command grep .

boredsquirrel@slrpnk.net on 05 Jun 2024 06:19 collapse

Thanks, good to know!

mwguy@infosec.pub on 11 Apr 2024 15:43 collapse

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

thingsiplay@beehaw.org on 11 Apr 2024 16:15 collapse

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@lemmy.ml on 11 Apr 2024 10:05 next collapse

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

thingsiplay@beehaw.org on 11 Apr 2024 10:18 collapse

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.

boredsquirrel@slrpnk.net on 04 Jun 2024 09:48 collapse

Oh I see you also had the flatpak issue where the developer name is used instead of the project name.

To solve this, use flatpak remove -y --force app && flatpak install app -y as there doesnt seem to be a fix to recreate the Metadata

github.com/flatpak/flatpak/issues/5700

I think some smart function is really needed, as many people will have messed up apps. For me it was 8 or more.

thingsiplay@beehaw.org on 04 Jun 2024 19:21 collapse

Thanks. I just checked it and don’t have the issue with developer name on Flatseal anymore. But good to know how to solve this issue when it happens again.

boredsquirrel@slrpnk.net on 04 Jun 2024 20:36 collapse

It doesnt happen again, the metadata parser was broken and metadata is not updated on updates, only on reinstall.

So you dont have this with Flatseal anymore?

thingsiplay@beehaw.org on 04 Jun 2024 21:23 collapse

Yes, it displays it correctly as

Flatseal                         com.github.tchx84.Flatseal

Maybe I did a reinstall, don’t remember.

boredsquirrel@slrpnk.net on 05 Jun 2024 06:19 collapse

Interesting