Star Hype News.

Premium celebrity moments with standout appeal.

news

create new filetype with existing extension

By Sarah Smith

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:

  1. I created a alpha.xml file 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.alpha file, I get an error saying:

    Could not display "abc.alpha". There is no application installed for "ALPHA File" files.
  2. I edited the /etc/mime.types file to include the following line:

    application/alpha zip
  3. I 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 .alpha file to open it in my program.

How do I solve this? Thanks in advance.

1 Answer

From Archlinux default applications:

  1. Create your xml file in ~/.local/share/mime/packages (I guess that /usr/share/mime/packages is also fine, but didn't test it)

    mkdir -p ~/.local/share/mime/packages
    touch ~/.local/share/mime/packages/application-alpha.xml
  2. Edit 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>
  3. 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=Application

    add the right exec path to your alpha application, and if this a console app change Terminal to true.

  4. 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.

4

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy