I have a mixed language project with some Assembler files, which have file extension “.s”. When any of the source directories containing Assembler files are displayed in Files/Nautilus, the .s files are shown like this:
Other files (.c, .cpp, etc.) show as text files. Right clicking on one of the .s files shows the following:
However, the file shell command shows them as ASCII text files:
someguy@somesys:~/projects/someproj/src$ file mzzflt*.s
mzzfltc.s: ASCII text
mzzfltr.s: ASCII text
I’m quite sure that this behaviour started recently, although I’m not in a position to prove it. I have the same behaviour on two systems running Ubuntu 22.04 LTS. On one of the two systems, double-clicking one of these files still opens the file in gedit. On the other, it tries unsuccessfully to open it in archive manager.
For both systems:
someguy@somesys::~$ nautilus --version
GNOME nautilus 42.6
Checking if there is anything stupid that I’ve missed.
shared-mime-info to determine the mime type of file. Maybe that package got updated recently? You can also check what the mime type of a file would be according to that using
xdg-mime query filetype mzzfltc.s to make sure the issue is not on the nautilus side.
shared-mime-info is at 2.1.2 (14 Jan 2022), so almost 2 years old. The output of
xdg-mime query filetype mzzfltc.s is consistent with what Nautilus properties for the file shows.
I found this in
<match type="string" value="MZ" offset="0"/>
The first two characters of the Assembler files happen to be “MZ”.
A quick test case:
someguy@somesys:~/projects/mimetest$ echo "MZ" > MZFile.s
someguy@somesys:~/projects/mimetest$ echo "mz" > mzFile.s
someguy@somesys:~/projects/mimetest$ xdg-mime query filetype MZFile.s
someguy@somesys:~/projects/mimetest$ xdg-mime query filetype mzFile.s
So it’s a quirk of the file contents. I couldn’t find any
<glob pattern="*.s"/>, so it seems that the initial “MZ” is determining the mime type. It’s clearly not Nautilus’s problem.
You can create own MIME type that overrides the defaults:
tee /tmp/custom.xml << EOF > /dev/null
<?xml version="1.0" encoding="utf-8"?>
<comment>Assembly source code</comment>
xdg-mime install --novendor /tmp/custom.xml
This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.