-
Notifications
You must be signed in to change notification settings - Fork 140
Opening files with MIME type preferences #314
Comments
Yo, I was wondering, whether you'd like to find out the mime-type or just use the extension in the file-name, since both would be possible. Clearly using the extension is easier, but using the mime-type might also be a risk, as something looking like a png could and up being a script or such. So I'd say let's go for extensions. I thought about simply using https://github.com/skratchdot/open-golang with optional caching in a non-temporary directory. I'd make it so that all data gets saved in the same folder and you can manually sort it out later if you will. Optionally there will be a config field where you can overwrite the actions for specific mimetypes:
The |
Made a little first version: https://github.com/Bios-Marcel/cordless/tree/file_open Sadly xdg-open, or furthermore that library that i use, doesn't seem to work and doesn't give any error. Either way, feel free to try: https://github.com/Bios-Marcel/cordless/tree/file_open You gotta check out that branch and compile it yourself. Additionally I added a default handler, in order to override the default of using the system-file-opener. A possible configuration looks like this: "FileOpenHandlers": {
"*": "custom-file-handler {$file}",
"jpg": "feh {$file}",
"mp4": "vlc -somearg 202 {$file}",
"png": "feh {$file}"
},
"FileOpenSaveFilesPermanently": false,
"FileOpenSaveFolder": "~/Downloads" This would also allow for example custom settings for the launch. For example Demo: |
I am not sure whether it's smarter to go with mimetype or file extension, because I don't know how accurate mimetype recognition is. But a cool thing might be allowing this "image/*": "feh {$file}"` |
I've pushed the current state to master for now, as I deem it pretty useful already. If you feel like your issue is solved, close it, otherwise tell me what's lacking. |
Actually, before i forget about it, I just close it. Just reopen it or make a new one if needed. |
What do you want
I request a feature that when the attached image button (Default O) is pressed that the file will be opened based on the mimetype (and mac/windows equivalent) preferences of the user. I.e: .pngs, .jpgs, .bpm, etc with feh and .mp4s, .webms., .oggs, etc with mpv or something of the likes. As another feature, there could be another shortcut that copys the link AND opens the media in the preferred application for those who like to save videos/images.
Why
As it stands, cordless only allows images to be displayed with little ease of customization for the end user, meaning video files are completely unplayable without copy and pasting and choice is limited on what the user can open a file. Using mimetypes would a Linux user to open any file they please in the program, .mp4s to mpv, .pngs to feh, .mid to wildmidi, etc. This would elevate the current issue of no embeds and would allow the user to user his or her preferred program.
Implementation hints
As said throughout this, MIMEtypes, and reading pull request #256 shows that you have obviously thought of this before, but only implemented images due to security concerns. Maybe have it as an optional config would allow the user to be given the choice (probably defaulting off for security).
The text was updated successfully, but these errors were encountered: