There seem to be some issues with filetype
identification and choosing the right application to display a file in the Dolphin
File Manager
Try this:
Find or make a small text file, eg
vi txt.txt
copy it as follows
cp txt.txt txt.jpg
cp txt.txt txt.pdf
cp txt.txt txt.orig
View these with Dolphin
Dolphin
seems to think txt.pdf
is a pdf file
and txt.jpg
is an image file
So lets try and display them
It gets txt.txt
and txt.orig
correctly displayed with KWrite
it tries to display txt.jpg
as an image file with Gwenview
and fails
it tries to display txt.pdf
as a pdf file with Okular
and succeeds because okular
can display text files.
So what is going on here. We can use Properties
to see what Dolphin
is doing, for example with txt.pdf
it gets
So Dolphin
knows the file Contents
are plain text document
but it sets the Type
to PDF document
.
Same for txt.jpg
. It gets the other two correct.
So where is Dolphin
getting its information from?
Go to command line and do
$ file txt* txt.jpg: ASCII text txt.orig: ASCII text txt.pdf: ASCII text txt.txt: ASCII text
So Linux file
command gets it right.
Now do
nevj@trinity:~ $ xdg-mime query filetype txt.txt text/plain nevj@trinity:~ $ xdg-mime query filetype txt.pdf application/pdf nevj@trinity:~ $ xdg-mime query filetype txt.jpg image/jpeg nevj@trinity:~ $ xdg-mime query filetype txt.orig text/plain
but xdg-mime
gets it wrong
So now we know. Dolphin
uses file
to determine the Content
but xdg-mime
to determine the Type
of each file.
and
Dolphin
then decides on a display application using the xdg-mime
result, and ignores the Content
.
Note this is not peculiar to Dolphin
. I found the same in Thunar
and Files
(Gnome)
Now some questions:
-
Is this the way you would like your File Manager to behave? My preference would be to have it work on the file
Content
, or at least offer a choice in its configuration. -
Can we find out how general this is? What does your File Manager do?
-
Can anyone come up with a File Manager that displays a file according to
Content
?
Final note:
There is a good article in file types here
and a wiki on using MIME here
https://wiki.archlinux.org/title/XDG_MIME_Applications
and also consult the Unix man
pages for file
and xdg-mime