3

Is it possible to set the default application to open a file by extension rather than mimetype?

MuseScore saves its files as .mscz files, which are actually just zip-archives containing the data of the MuseScore file. Since Ubuntu recognizes it as a zip-archive, it opens them with the archive manager. So I always have to right-click and say Open with MuseScore, which is annoying.

If I set MuseScore as default for the .mscz files, it becomes the default for all zip-archives, which is obviously not what I want. So it would be useful if I could set MuseScore as default for all files with the .mscz extension.

As far as I know, I don't have any .mscz archives that are not MuseScore files, so that wouldn't be a problem. And if I ever do encounter some, I don't mind dealing with that.

1 Answer 1

2

Try the following:

  1. Use nano to create the /usr/share/mime/packages/musescore3.xml file:

    sudo nano /usr/share/mime/packages/musescore3.xml
    
  2. Copy and paste (with Ctrl+Shift+V) the following:

    <?xml version="1.0" encoding="UTF-8"?>
    <mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
      <mime-type type="application/x-musescore3">
        <comment>MuseScore file</comment>
        <sub-class-of type="application/zip"/>
        <glob pattern="*.mscz"/>
      </mime-type>
      <mime-type type="application/x-musescore3+xml">
        <comment>uncompressed MuseScore file</comment>
        <sub-class-of type="application/xml"/>
        <glob pattern="*.mscx" />
      </mime-type>
      <mime-type type="application/vnd.recordare.musicxml3">
        <!-- http://www.musicxml.com/for-developers/musicxml-dtd/ -->
        <_comment>compressed MusicXML file</_comment>
        <sub-class-of type="application/zip"/>
    <!-- Note: a custom icon is used for MusicXML files. You can change this below -->
    <!--  <icon name="application-x-musescore"/> Uncomment to use MuseScore file icon -->
    <!--  <generic-icon name="audio-x-generic"/> Uncomment to use generic audio file icon -->
        <glob pattern="*.mxl"/>
      </mime-type>
      <mime-type type="application/vnd.recordare.musicxml3+xml">
        <!-- http://www.musicxml.com/for-developers/musicxml-dtd/ -->
        <_comment>uncompressed MusicXML file</_comment>
        <sub-class-of type="application/xml"/>
    <!--  <icon name="application-x-musescore"/> Uncomment to use MuseScore file icon -->
    <!--  <generic-icon name="audio-x-generic"/> Uncomment to use generic audio file icon -->
        <magic>
          <match type="string" value="&lt;?xml" offset="0">
            <match type="string" value="score-partwise" offset="0:128"/>
            <match type="string" value="score-timewise" offset="0:128"/>
          </match>
          <match type="string" value="&lt;!--" offset="0">
            <match type="string" value="score-partwise" offset="0:128"/>
            <match type="string" value="score-timewise" offset="0:128"/>
          </match>
        </magic>
        <glob pattern="*.xml" weight="40"/>
      </mime-type>
      <mime-type type="application/vnd.recordare.musicxml3+xml">
            <!-- http://www.musicxml.com/for-developers/musicxml-dtd/ -->
            <_comment>uncompressed MusicXML file</_comment>
            <sub-class-of type="application/xml"/>
            <!--  <icon name="application-x-musescore"/> Uncomment to use MuseScore file icon -->
            <!--  <generic-icon name="audio-x-generic"/> Uncomment to use generic audio file icon -->
            <magic>
                  <match type="string" value="&lt;?xml" offset="0">
                        <match type="string" value="score-partwise" offset="0:128"/>
                        <match type="string" value="score-timewise" offset="0:128"/>
                  </match>
                  <match type="string" value="&lt;!--" offset="0">
                        <match type="string" value="score-partwise" offset="0:128"/>
                        <match type="string" value="score-timewise" offset="0:128"/>
                  </match>
            </magic>
            <glob pattern="*.musicxml" weight="40"/>
      </mime-type>
    </mime-info>
    
  3. Save and close nano using Ctrl+O and Ctrl+X.

  4. Run:

    sudo update-mime-database /usr/share/mime
    
  5. Then right-click a .mscz file and then go to PropertiesOpen With → select MuseScore from the list → Set as default.

  6. If that doesn't work immediately, repeat step 5 to set the default program (Archive Manager) for a zip file and then repeat for Musescore.

The following screenshot is an example of the Properties window.

Properties

2
  • That works nicely, thanks. So if I understand correctly, this basically creates a new mimetype that is applies to all zip files that contain the pattern .mscz, right? Cool, maybe in the future I'll use this as an example to create my own mimetypes when needed.
    – Lu Kas
    Oct 26, 2020 at 8:32
  • Glad it worked! Yes, that's what it does. BTW, this file was created by MuseScore when I installed it to try it. I don't know why it wasn't created for you by MuseScore too, but I guess there is no point in trying to find out now that you solved it! Oct 26, 2020 at 8:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .