Change file association for certain text file type in Gnome

Hello guys,

I’ve switched over from KDE to a fresh Manjaro Gnome installation a couple of weeks ago and love it so far. It really suits my workflow since I’m often working from a laptop on the go.

Anyhow, there is one thing I was not able to change: The file association of .vsz files generated by Veusz. It’s a plotting tool written in python which saves its work state basically as a python script in a plain text file.

Example of a .vsz file
# Veusz saved document (version 3.6.2)
# Saved at 2024-04-07T11:20:24.564120

SetCompatLevel(1)
AddImportPath('/home/fabian/Desktop')
Add('page', name='page1', autoadd=False)
To('page1')
Add('graph', name='graph1', autoadd=False)
To('graph1')
Add('axis', name='x', autoadd=False)
Add('axis', name='y', autoadd=False)
To('y')
Set('direction', 'vertical')
To('..')
To('..')
To('..')

The installation creates a .desktop file with a MimeType application/x-veusz:

Summary
[Desktop Entry]
Name=Veusz
GenericName=Scientific plotting
GenericName[ca]=Traçador científic
GenericName[de]=Wissenschaftliches Plotten
...
GenericName[zh_CN]=科学绘图
Comment=Scientific plotting and graphing package
Comment[ca]=Paquet de traçament i grafisme científic
Comment[de]=Wissenschaftliches Plott- und Darstellungspaket
...
Comment[sv]=Vetenskapligt plottnings- och grafritningspaket
MimeType=application/x-veusz;
Exec=veusz %F
Icon=veusz
Terminal=false
Type=Application
Categories=DataVisualization;Science;
Keywords=graphing;plotting;graph;plot;visualization;visualisation;science;math;maths;mathematics;data;

I’ve already tried xdg-mime default veusz.desktop application/x-veusz which probably created
application/x-veusz=veusz.desktop
in my user specific ~/.config/mimeapps.list.

Unfortunately file --mime-type test.vsz still returns
test.vsz: text/plain
so it is still recognized as a standard text file and opened in the default gedit.

Does anybody has an idea how I change the mimetype to application/x-veusz? If necessary, at least manually for each .vsz file I create?
I’ve found xdg-mime set filetype test.vsz application/x-veusz but that apparently did not change anything.

Many thanks in advance!

I wonder if Veusz has a mimetype placed in /usr/share/mime/packages/ for example.

Example of keepasscx:

File: /usr/share/applications/org.keepassxc.KeePassXC.desktop

[Desktop Entry]
Name=KeePassXC
[...]
Exec=keepassxc %f
TryExec=keepassxc
Icon=keepassxc
StartupWMClass=keepassxc
StartupNotify=true
Terminal=false
Type=Application
Version=1.5
Categories=Utility;Security;Qt;
MimeType=application/x-keepass2;
SingleMainWindow=true
X-GNOME-SingleWindow=true

File: /usr/share/mime/packages/keepassxc.xml

<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
  <mime-type type="application/x-keepass2">
    <comment>KeePass 2 Database</comment>
    <glob pattern="*.kdbx"/>
    <icon name="application-x-keepassxc"/>
  </mime-type>
</mime-info>

You would need the same for Veusz.

Probably take a look here. Redhat has really good article here: 12.3. Configuring File Associations Red Hat Enterprise Linux 7 | Red Hat Customer Portal

1 Like

Thanks for the advice! That was the right path for me!
Indeed, there was no file /usr/share/mime/packages/veusz.xml, at least on my installation.

I’ve created one with:

<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
  <mime-type type="application/x-veusz">
    <comment>Veusz save file</comment>
    <glob pattern="*.vsz"/>
    <icon name="application-x-veusz"/>
  </mime-type>
</mime-info>

According to the site you’ve linked, I did also

# update-mime-database /usr/share/mime
# update-desktop-database /usr/share/applications

But only after logging out and back in, .vsz files are correctly opened by Veusz!

Now I only have to figure out the correct icon, since with <icon name="application-x-veusz"/> it’s a file with an exclamation mark. :sweat_smile:

PS:
For a test and as I don’t have gvfs-info installed, I did

> touch test.vsz
> file --mime-type test.vsz
test.vsz: inode/x-empty

and it is opened by gedit.
But files created from within Veusz work fine:

> file --mime-type test.vsz
test.vsz: text/plain

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