Mystery input requested: why does "Open Application With" not like command line applications when launched from a flatpak app

Hello everyone, nice to see you around. :waving_hand:

I’m requesting input with some ideas for the following, on 1. why this is happening, and 2. if with portals this should be happening, and 3. if it would be reasonable to suggest improvements to make this work and what those could be.

The mystery in question is, why does “Open Application With” not like command line applications when launched from a flatpak app as described here.

Summed up, the situation seems to be a /usr/bin/vlc on the host that has no .desktop file, while a sandboxed flatpak Brave can’t use that in the “Open Application With” dialog to open a file for playback. I’m wondering why that can’t work and if it shouldn’t work. The .desktop file seems related, but still, KDE’s open with mechanism seems designed to allow arbitrary command line apps with “Run in Terminal”, so this seems inconsistent.

I’m curious about input.

1 Like

i would think you could make a .desktop file that called a command line tool and then assign that as one of the applications to associate with the file you are trying to open.

you may need to script the command line or include a console in the .desktop executable part, but i don’t see why that wouldn’t work.

I think I could, but shouldn’t it perhaps work without one? Is there like, some legit security concern even when using a portal why that would be a bad idea? Most command line tools simply don’t have a .desktop file yet can be used for open with.

Sorry that this forum thread is so meta.

i have imagemagick installed (which is a bag of command line tools) and when i right click on an image file to open with imagemagick it calls the display command to show the image in a viewer.

how would the desktop know to do that without a .desktop file that requires the display command over, say, any of the other dozens of commands?

The default is simply to put the target file as argument, I think. Outside of flatpak no .desktop file is required to do that with any arbitrary command line binary.

this topic started off with using the “open application with…” context menu.

that context menu only makes sense when there is a file to pass as an argument to a command… in other words, when there is a context

i guess i’m now confused about what you are asking.

My apologies for the confusion. What would you like me to clarify?

i read the bug report and it seems they have answered the question.

the DE requires a .desktop file for it to be aware of an application

making a .desktop file in your ~/.local/share/applications/ will allow you to use the desktop GUI to add things to that context menu for your use case.

1 Like

Thank you so much.

Outside of flatpak the .desktop file really isn’t required. Inside flatpak, it apparently is. My follow-up proposal or question is, is that really an unavoidable requirement, and what would best be suggested and where, to get that revisited?

you are likely seeing this because you don’t have the proper command line parameters called out in the file association.

i made up a file called emptyfile.munch on my desktop.

then i found a flatpack that i want to use to open it, and because it created a .desktop file for me upon install, i have an example of how to evoke it form the command line

first i needed to run the flatpak binary

/usr/bin/flatpak

then i need to pass it the command line arguments that let it open the file that is passed to it by the open with dialog.

run --branch=stable --arch=x86_64 --command=marktext --file-forwarding com.github.marktext.marktext @@ %F @@

yup, that’s a doosy and there is no way i would have figure that out on my own, but i’m a noob.

so to open the file in marktext i simply right click on it, open with other application…

and choose the browse option in order to navigate to the binary and then paste the command line arguments in window after the binary call so the whole text window looks like

/usr/bin/flatpak run --branch=stable --arch=x86_64 --command=marktext --file-forwarding com.github.marktext.marktext @@ %F @@

then i choose the check box that says “remember”

along with the check boxes for run in a terminal and keep it open so i can see any errors that it might generate (helps maybe figure this out, if you don’t have an example), and hit save.

from then on when i double click on my .munch file it opens up in marktext with out issue, and im confident that it would do so even without the .desktop file because it’s not being used.

The question isn’t about a document outside of the sandbox, but a program. Sorry for the confusion! It seems like your steps did the problem in reverse. Or perhaps I misread your response.

i was going off your steps

STEPS TO REPRODUCE

1. Install com.brave.Browser from flathub
2. Download some file that has no app associated with the file type, or the app associated with it is some command line app without a .desktop file
3. In the open with application dialog that should pop up, try to enter the command line app path

the only reason to using the Open With… item in the context menu is to open a file with an application.

i guess i still have to go back to my not understanding what you are asking here.

you keep going back and forth between two mutually exclusive things and i guess i can’t keep up.

good luck.

I was asking a conceptual question what is stopping the workflow attempted in the bug report to work and how it could be made to work, not a practical question for workarounds. Sorry for the misunderstanding!