New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mime type determination #77
Comments
spacefm gets its mime info from the mime database in freedesktop.org's shared-mime-info package. If you run this:
As you can see, globs are used to define *.iso as x-cd-image, so that's where that's coming from in spacefm. So no, mime types are not necessarily independent of file extension. If you run:
There is no output, meaning that type is not defined in freedesktop's database. Likewise:
Other programs don't necessarily use freedesktop's database. For example, 'file' uses it's own database stored in /usr/share/file. xdg-mime is merely a wrapper that runs whatever mime typing program it can find, eg file, kfile, mimetype, gnomevfs-info, etc. spacefm doesn't run an external program (it would be far too slow for the number of files it needs to identify when opening a directory). If for some reason you want *.iso to be identified as x-iso9660-image, you can create this type yourself and add it to your mime database, either as a user or system-wide. http://www.freedesktop.org/wiki/Specifications/AddingMIMETutor The current spacefm next branch, which will become the release following 0.7.7, can create such xml files automatically. Right-click on a file, enter the Open submenu, right-click on one of the applications listed, then select the xml file. It will create the file, which you can then edit and rename to create your x-iso9660-image filetype. Then run
which spacefm can also do (in the same app menu). That will be for your user only, but you can always install it to /usr/share/mime/packages to make it system-wide. If you think freedesktop should identify *.iso as x-iso9660-image, you should file a request with them on that change - I don't know what the reason is for the difference. spacefm also installs /usr/share/mime/packages/spacefm-mime.xml, which defines a few missing types (this file's contents predates spacefm). x-iso9660-image could be added there, but I'm not sure what the purpose would be or if it's worth deviating from the freedesktop database. |
Thank you for a comprehensive explanation. So, I guess spacefm uses file On Wed, May 30, 2012 at 1:30 PM, IgnorantGuru <
|
Not necessarily. spacefm uses the mime database on your system. Some mime types use globs in their definition (eg *.iso). Others use magic detection (examine the file contents to determine type). And some use a combination. This is defined in the mime database and the behavior for a given type can be customized how you like on your system. If you want it done automagically you can do so. You can see this with files that have no extension - spacefm still knows the file type (depending on what the mime database has for magic on that file type). |
I have a cd image file named cd.iso and spacefm shows its file type to be application/x-cd-image. I change its filename to cd.img and spacefm shows its file type as application/x-executable. I change its filename to cd.iso~ and spacefm shows its file type as application/x-trash. I checked all 3 filenames with "file" and "xdg-mime" commands, and all show file type to be application/x-iso9660-image. I thought mime file type is supposed to be independent of file extension but it seems like spacefm is using file extension to determine mime type. Is this the intended behavior?
The text was updated successfully, but these errors were encountered: