Mime database

I have a file that defines the mime type for my application, and a desktop file for it:
com.github.deepskystacker-x-text-dssfilelist.xml

<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
    <mime-type type="text/dssfilelist">
        <comment>DeepSkyStacker file-list file</comment>
        <glob pattern="*.dssfilelist" />
    </mime-type>
</mime-info>

DeepSkyStacker.desktop

[Desktop Entry]
Type=Application
Exec=/opt/DeepSkyStacker/DeepSkyStacker
Name=DeepSkyStacker
GenericName=The preferred application for stacking astronomical images
MimeType=text/dssfilelist
Icon=/opt/DeepSkyStacker/DeepSkyStacker.icns
Categories=Astronomy;Science

When I install my application I do:

sudo xdg-mime install /opt/DeepSkyStacker/com.github.deepskystacker-x-text-dssfilelist.xml
sudo desktop-file-install /opt/DeepSkyStacker/DeepSkyStacker.desktop

when I uninstall the application I do:

sudo xdg-mime uninstall /opt/DeepSkyStacker/com.github.deepskystacker-x-text-dssfilelist.xml
sudo rm -f /usr/share/applications/DeepSkyStacker.desktop
sudo rm -f /usr/share/applications/DeepSkyStackerLive.desktop
sudo update-mime-database /usr/share/mime
sudo update-desktop-database /usr/share/applications/

After that any files with extension .dssfilelist shouldn’t have my icon associated with them, but they still do???

What have I missed?

Thanks
David

GNOME is still showing the icon because a per-user MIME cache and file-type association are left behind in your home directory; the system-wide files you removed don’t touch those.

What’s still hanging around

  • $HOME/.local/share/mime/packages/com.github.deepskystacker-x-text-dssfilelist.xml
  • $HOME/.local/share/applications/mimeapps.list (line that saystext/dssfilelist=DeepSkyStacker.desktop;)
  • The user-level MIME cache in $HOME/.local/share/mime/mime.cache

Quick clean-up

#Remove the user copy of the MIME definition (if it exists)
rm -f ~/.local/share/mime/packages/com.github.deepskystacker-x-text-dssfilelist.xml

#Remove the association from your personal mimeapps list
sed -i '/text\/dssfilelist/d' ~/.local/share/applications/mimeapps.list

#Rebuild the user MIME cache
update-mime-database ~/.local/share/mime

Then log out and back in (or restart your file manager).

The .dssfilelist files will fall back to the generic text icon.

(If you want to automate it, run the same three steps in your uninstall script no sudo needed, because they touch only the current user’s home directory.)

That sounded reasonable, but there’s no mime directory in ~/.local/share, and ~/.local/share/applications just contains:

amonra@styx:~/.local/share/applications$ ls -l
total 4
-rw-rw-r-- 1 amonra amonra 13 May  7 10:23 mimeinfo.cache
amonra@styx:~/.local/share/applications$ cat mimeinfo.cache                                                                    
[MIME Cache]                                                                                                                   
amonra@styx:~/.local/share/applications$ 

So, more ideas needed …

PS Should it be relevant I’m running lxQt …
David

xdg-mime install (when run with sudo) copies your XML into
/usr/local/share/mime/packages/.
Likewise, desktop-file-install drops a copy of the desktop file in
/usr/local/share/applications/.

So even after you delete the originals in /opt, the copies in /usr/local
are still there, update-mime-database keeps finding them, and Nautilus keeps
using your icon.


Clean-up steps

#Remove the mime-type definition that was copied to /usr/local
sudo rm -f /usr/local/share/mime/packages/com.github.deepskystacker-x-text-dssfilelist.xml

#Rebuild the MIME database
sudo update-mime-database /usr/local/share/mime
sudo update-mime-database /usr/share/mime      # safe to run too

#Delete the desktop file copy
sudo rm -f /usr/local/share/applications/DeepSkyStacker.desktop

#Rebuild the desktop cache
sudo update-desktop-database

Log out/in (or killall nautilus) and the .dssfilelist files should go
back to the generic icon.


Tip for next time

Use the explicit mode option so xdg-mime touches the location you expect:

#install system-wide
sudo xdg-mime install --mode system com.github.deepskystacker-x-text-dssfilelist.xml

#uninstall system-wide
sudo xdg-mime uninstall --mode system com.github.deepskystacker-x-text-dssfilelist.xml

That way no hidden copy ends up in /usr/local/share and uninstalling is a
one-liner.

It turned out to be simpler than that - the file for registering the mime type previously had a different name.

Using the old name and running

sudo su
xdg-mime uninstall text-dssfilelist.xml
update-mime-database /usr/share/mime
update-desktop-database /usr/share/applications/

fixed the problem (as you said, xdg-mime had cached the OLD xml file)

Thanks for the assist
David

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.