修改linux desktop entry 默认打开方式

来源:互联网 发布:太原培训网络 编辑:程序博客网 时间:2024/05/16 14:08

转自:http://www.jianshu.com/p/4b1a1b049896点击打开链接

修改默认打开程序

多种方法:

  1. 使用系统Details程序修改( System > Details > Default Applications),仅可以修改少数程序:

    Paste_Image.png
  2. 添加应用程序到Application list,并通过Nautilus的open with 方法修改打开程序。(下文介绍)
  3. 修改文件MIME文件替换自己的指定的程序为默认程序。MIME配置方法可以考:Linux MIME type

参考URL:
http://blog.sina.com.cn/s/blog_65a7a4d40101artf.html

添加新应用程序到GUI Application list及Nautilus文件管理器的open with 程序列表:

添加新程序到GUI的application list和open with list需要如下两个步骤,缺一不可:

  1. 需要在如下指定路径下有对应<程序名>.desktop文件存在:

    • /usr/share/applications/<filename>.desktop 系统全局路径
    • ~/.local/share/applications/<filename>.desktop 个人用户路径
      必须为这两个系统级别路径,虽然其他目录下的.desktop GNOME也可以发现,并通过搜索启动,但是打开方式是不认的!!!

      .desktop文件又称为Desktop_entry,是当前最主要的GUI环境下启动程序的方式。其是freedesktop.org标准化的在Xorg下执行程序的方法,文件指定了程序的执行方式,以及在目录下的icon图标。目前有三类.desktop文件:

      • Application :a shortcut to an application
      • Link :a shortcut to a web link.
      • Directory :a container of meta data of a menu entry
        参考文档:ArchLinux Wiki Desktop_entries
  2. 文件内容中Exec 条目结尾需要增加 %f符号(必须,否则不会出现在打开程序列表中),将打开的文件传递给启动程序

    ray@ray-ThinkPad-X250:~/.local/share/applications$ cat yEd.desktop #!/usr/bin/env xdg-open[Desktop Entry]Type=ApplicationName=yEd Graph EditorExec=/bin/sh "/home/ray/Applications/yEd/yEd" %fIcon=/home/ray/Applications/yEd/.install4j/yEd.pngCategories=Application;ray@ray-ThinkPad-X250:~/.local/share/applications$

    %f符号含义参考文档:Desktop Entry Specification

  3. 更新.desktop文件后更新并注销系统才能生效

    sudo update-desktop-databae ~/.local/share/applications
    logout

参考URL:
https://ubuntugenius.wordpress.com/2012/06/18/ubuntu-fix-add-program-to-list-of-applications-in-open-with-when-right-clicking-files-in-nautilus/#comment-2353
http://askubuntu.com/questions/270344/how-to-associate-file-types-with-wine-in-nautilus
https://ubuntugenius.wordpress.com/2012/06/18/ubuntu-fix-add-program-to-list-of-applications-in-open-with-when-right-clicking-files-in-nautilus/



作者:mst7
链接:http://www.jianshu.com/p/4b1a1b049896
來源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

原创粉丝点击