Thursday, May 2, 2024
 Popular · Latest · Hot · Upcoming
7
rated 0 times [  7] [ 0]  / answers: 1 / hits: 9332  / 1 Year ago, sat, december 17, 2022, 5:48:03

I recently switched to GNOME 3 and was surprised to find that there was no way by which we could set the default applications. I am writing a Nautilus extension using Bash. I want to find the MIME type of a file.



Initially I used to extract the extension of the file using sed and build the code on it. Then I realized that there is this command called file. When I try to find the mime-type of a mkv file, the command file --mime-type -b <filename> outputs application/octet-stream but when I see the Nautilus properties window it shows the correct video/x-matroska mime-type.



Am I missing anything here? If not is there a better way in which I can file the mime-type of a file?


More From » bash

 Answers
2

There are different ways to get a MIME type on Linux, and they often lead to different results. Use



xdg-mime query filetype your_file


to get the same MIME type as Nautilus gets.


[#40421] Saturday, December 17, 2022, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
beateyra

Total Points: 499
Total Questions: 113
Total Answers: 125

Location: Falkland Islands
Member since Mon, Jul 13, 2020
4 Years ago
;