create new filetype with existing extension
I made a Qt application, let's call it "alpha," that opens and generates .zip files. So basically, my files created by the app have the extension .alpha but they are basically .zip files. How do I associate .alpha files with my "alpha" application? Currently, by default, the .alpha files open with archive manager (because the system sees them as .zip files).
I looked at many possible solutions, with no success. I have tried the below methods:
I created a
alpha.xmlfile in/usr/share/mime/packages<?xml version="1.0" encoding="UTF-8"?> <mime-info xmlns=' <mime-type type="application/alpha"> <comment>ALPHA File</comment> <glob pattern="*.alpha"/> </mime-type> </mime-info>Now when I click
abc.alphafile, I get an error saying:Could not display "abc.alpha". There is no application installed for "ALPHA File" files.I edited the
/etc/mime.typesfile to include the following line:application/alpha zipI created the file
alpha.desktop- this works fine, as ALPHA is now shown in "open with other applications." However I still can't double click a.alphafile to open it in my program.
How do I solve this? Thanks in advance.
1 Answer
From Archlinux default applications:
Create your xml file in
~/.local/share/mime/packages(I guess that/usr/share/mime/packagesis also fine, but didn't test it)mkdir -p ~/.local/share/mime/packages touch ~/.local/share/mime/packages/application-alpha.xmlEdit
application-alpha.xml:<?xml version="1.0" encoding="UTF-8"?> <mime-info xmlns=""> <mime-type type="application/alpha"> <comment>alpha file</comment> <glob-deleteall/> <glob pattern="*.alpha"/> </mime-type> </mime-info>Now create the desktop file
~/.local/share/applications/alpha.desktop:[Desktop Entry] Name=Alpha Exec=/PATH/TO/YOUR/alpha MimeType=application/alpha Terminal=false Type=Applicationadd the right exec path to your alpha application, and if this a console app change Terminal to true.
Now update the applications and mime database with:
update-desktop-database ~/.local/share/applications update-mime-database ~/.local/share/mime
Now if you double click your abc.alpha file /PATH/TO/YOUR/alpha app should open your file.