sonnyp / Junction

Application/browser chooser
https://flathub.org/apps/re.sonny.Junction
GNU General Public License v3.0
457 stars 28 forks source link

Set as default for images and video #119

Open gregorni opened 1 year ago

gregorni commented 1 year ago

According to feedback from app reviews, setting Junction as default for opening images and videos with a button (similar to how it's set for web links right now) would be a nice feature.

gregorni commented 1 year ago

This issue raises some questions, like: If the app can be set as default for images, why not also make a button for setting it as default for text files, PDFs, audio, etc.? But how should all these buttons fit in the welcome window? And if that's already there, why not just make one button that sets the app as default for everything in one go?

sonnyp commented 1 year ago

that sets the app as default for everything in one go?

Maybeeeee? We would have to ship the list of all known mime types and add an option in Junction "Remember" so you can opt out for certain types.

If the app can be set as default for images, why not also make a button for setting it as default for text files, PDFs, audio, etc.? But how should all these buttons fit in the welcome window?

My first thought was to do something similar to gcc "Default Apps" panel. But I agree it doesn't work too well with Junction.

Perhaps we could do a list of well known types and let user add new mime types.

sonnyp commented 1 year ago

IIRC @BrainBlasted had thoughts on this when I released Junction

sonnyp commented 1 year ago

This is how we currently set Junction as default app https://github.com/sonnyp/Junction/blob/d4b34d731a6b561e01e2976b4d97337b1c99eefd/src/welcome.js#L37

Note that spawn_sync uses flatpak-spawn --host in Flatpak.

gregorni commented 1 year ago

We would have to ship the list of all known mime types and add an option in Junction "Remember" so you can opt out for certain types.

There is also a problem here, because "all mimetypes" also includes stuff like AppImages, which you might not want to open in Junction.

Also, I noticed going through all image and video mimetypes is also a hassle, because you have really many uncommon formats like heic, avif and bmp, and sometimes even app-specific ones like totem-stream, whatever that is, where I'm not sure if they belong in Junction. So the sheer amount of mimetypes might already become a problem.

gregorni commented 1 year ago

This is how we currently set Junction as default app

https://github.com/sonnyp/Junction/blob/d4b34d731a6b561e01e2976b4d97337b1c99eefd/src/welcome.js#L37

Note that spawn_sync uses flatpak-spawn --host in Flatpak.

Yeah, that's fine. A slightly modified version of that function can be used to set Junction as default for whatever mimetypes you want, but making 50+ setAsDefaultApplicationForX functions seems kind of clunky to me.

Mimetypes/Filetypes are a mess.

sonnyp commented 1 year ago

gio mime isn't the only way to set associations

There is also ~/.config/mimeapps.list

gregorni commented 1 year ago

gio mime isn't the only way to set associations

There is also ~/.config/mimeapps.list

I guess that could also be used. How would that make things easier?

sonnyp commented 1 year ago

We can add numerous entries at once by writing to that file.

GLib has a parser/serializer for this format https://docs.gtk.org/glib/struct.KeyFile.html

gregorni commented 1 year ago

We can add numerous entries at once by writing to that file.

GLib as a parser/serializer for this format https://docs.gtk.org/glib/struct.KeyFile.html

Oh, okay, that's smart. Should be fairly easy in terms of code