7.5. 为所有用户覆盖默认注册的应用程序

作为系统管理,您可以根据要求更新配置。系统管理员的配置优先于默认的软件包配置。每一种情况,特定于桌面的配置都优先于不指定桌面环境的配置。

流程

  1. 查阅 /usr/share/applications/mimeapps.list 文件,来确定您要更改的默认注册的应用程序的 MIME 类型。例如,以下 mimeapps.list 文件示例指定了 text/htmlapplication/xhtml+xml MIME 类型的默认注册的应用程序:

    [Default Applications]
    text/html=firefox.desktop
    application/xhtml+xml=firefox.desktop

    上面的例子通过指定相应的 .desktop(firefox.desktop )来指定默认的应用程序(Firefox)。您可以在 /usr/share/applications/ 目录中找到其他应用程序的 .desktop 文件。

  2. 创建 /etc/xdg/mimeapps.list 文件,并在此文件中指定 MIME 类型及其相应的默认注册的应用程序。

    [Default Applications]
    text/html=myapplication1.desktop
    application/xhtml+xml=myapplication2.desktop

    上面的例子将 text/html MIME 类型的默认注册的应用程序设置为 myapplication1.desktop,并将 application/xhtml+xml MIME 类型设置为 myapplication2.desktop

验证步骤

  • 要使这些设置正常工作,请确保 myapplication1.desktopmyapplication2.desktop 文件都放在 /usr/share/applications/ 目录中。
  • 执行 gio mime query 命令,来验证默认注册的应用程序是否已正确设置。

    $ gio mime text/html
    Default application for 'text/html': myapplication1.desktop
    Registered applications:
    	myapplication1.desktop
    	firefox.desktop
    Recommended applications:
    	myapplication1.desktop
    	firefox.desktop