通过扩展名而不是 mimetype 设置默认应用程序

通过扩展名而不是 mimetype 设置默认应用程序

是否可以将默认应用程序设置为通过扩展名而不是 mimetype 打开文件?

MuseScore 将其文件保存为 .mscz 文件,这些文件实际上只是包含 MuseScore 文件数据的 zip 存档。由于 Ubuntu 将其识别为 zip 存档,因此它会使用存档管理器打开它们。所以我总是必须右键单击并说使用 MuseScore 打开,这很烦人。

如果我将 MuseScore 设置为 .mscz 文件的默认设置,它将成为所有 zip 存档的默认设置,这显然不是我想要的。因此,如果我可以将 MuseScore 设置为所有扩展名为 .mscz 的文件的默认设置,那将非常有用。

据我所知,我没有任何非 MuseScore 文件的 .mscz 档案,所以这不是问题。如果我遇到一些,我不介意处理它。

答案1

请尝试以下操作:

  1. 用于nano创建/usr/share/mime/packages/musescore3.xml文件:

    sudo nano /usr/share/mime/packages/musescore3.xml
    
  2. 复制并粘贴(使用++ Ctrl)以下内容:ShiftV

    <?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. nano使用Ctrl+OCtrl+保存并关闭X

  4. 跑步:

    sudo update-mime-database /usr/share/mime
    
  5. 然后是right-click一个 .mscz 文件,然后转到特性打开用→ 选择MuseScore从列表 → Set as default

  6. 如果这不能立即起作用,请重复步骤 5 以设置 zip 文件的默认程序(存档管理器),然后对 Musescore 重复此操作。

以下屏幕截图是特性窗户。

特性

相关内容