将应用程序添加到gnome3的全局菜单中(并支持修改为默认程序)

来源:互联网 发布:nike淘宝店推荐 编辑:程序博客网 时间:2024/06/03 20:31

在gnome3中,如果将鼠标移动到左上角,就会出现一个程序选单,类似于win8中的start界面,在这里直接键入英文就可以快速索引程序,十分方便。不过像deadbeef(笔者喜欢的一个轻量级音乐播放器)这种从网上获取的可执行文件无法作为程序出现在gnome3的程序选单中,而且也无法添加为播放.mp3的默认程序,所以才需要使用如下方法

# cd /usr/share/applications/

# vim deadbeef.desktop

[Desktop Entry]
Name=Deadbeef
GenericName=Music Player
Comment=Deadbeef
Exec=/home/yting/Downloads/deadbeef-0.6.2/deadbeef %U
Icon=/home/yting/Downloads/deadbeef-0.6.2/deadbeef.png
Terminal=false
Type=Application
Categories=Music
StartupNotify=false

这里说明一下,关键是我们自己建立的.desktop文件,这个文件可以放到两个目录下起作用,分别是~/.local/share/applications与cd /usr/share/applications/,如果放到前者下,则仅对当前用户有效,如果放到后一个目录,则所有用户都可以直接在gnome3程序选单中运行该程序


.desktop文件中的格式是固定的,下面解释一下:

[Desktop Entry]->固定,不可变
Name=Deadbeef->名字直接影响索引,按照程序的不同可以换不同名字
GenericName=Music Player->这行可以去掉
Comment=Deadbeef->这行可以去掉
Exec=/home/yting/Downloads/deadbeef-0.6.2/deadbeef %U->重点在这,路径不能写错,后面的%U在Table1-2说明
Icon=/home/yting/Downloads/deadbeef-0.6.2/deadbeef.png->图标
Terminal=false->不在终端运行
Type=Application->说明这是个应用,其他可选值(Link,Directory)
Categories=Music
StartupNotify=false

Table 1-2Exec variables
Add...Accepts...%fa single filename.%Fmultiple filenames.%ua single URL.%Umultiple URLs.%da single directory. Used in conjunction with %f to locate a file.%Dmultiple directories. Used in conjunction with %F to locate files.%na single filename without a path.%Nmultiple filenames without paths.%ka URI or local filename of the location of the desktop file.%vthe name of the Device entry.

0 0
原创粉丝点击