1

I know that I can use xdg-mime default codium.desktop text/plain to change association for text\plain mimetype ( Programatically modify file associations using standard interface (using mimetype) )

But for example file --mime-type -b index.ts reports also text\plain and xdg-mime query default text/plain reports codium.desktop

But index.ts file is opened by "Qt Linguist". Unlike say wat.txt file that is opened as expected, by Codium.

As result xdg-mime default codium.desktop text/plain has no effect whatsoever.

Is there some standard CLI option to override whatever sets such default? I am fine with it being Ubuntu specific or even Lubuntu specific. Though I would prefer it as broad as possible.

I know that I can set settings to something sane with GUI - but I want to add it to system setup scripts and avoid doing it manually on every system reinstall.

I now discovered ~/.config/mimeapps.list that now contains line: text/vnd.qt.linguist=codium.desktop; triggered by manual adding file association (no idea why .ts file is captured by Qt but...).

Running xdg-mime default codium.desktop text/vnd.qt.linguist liberated .ts file from Qt tyranny and now opens in Codium as I want to happen with TypeScript files (fortunately I do not care about qt.linguist files at all, so misclassification is not affecting me)

So how can I see actual mime type? In cases where file --mime-type -b fails?

Is text/vnd.qt.linguist a mimetype?


I noticed that file properties GUI is displaying MIME type diverging from one reported by file --mime-type -b. How can I get proper MIME type without using GUI?

enter image description here

1 Answers1

1

You were missing the use of xdg-mime on a specific file.

How can I see actual mime type?
Try

$ xdg-mime query filetype index.ts

or

$ mimetype index.ts

It seems file examines the contents of the file, while xdg-mime uses a combination of methods to determine the MIME type, including some times calls to file. I didn't find so far a specification of the algortihm used by xdg-mime to decide on the MIME type, but this info is so far enough for your purpose, I guess.

Is text/vnd.qt.linguist a mimetype?
Yes.

Related:

  1. Why the difference between the results with "file --mime-type" and "xdg-mime query filetype"?
  2. What is the relationship between MIME types and File .extensions?
  3. https://gitlab.freedesktop.org/xdg/shared-mime-info/-/issues/10
  4. https://unix.stackexchange.com/questions/565202/kde-is-not-saving-a-mime-type-file-association