Linux开始菜单的编辑和配置 您所在的位置:网站首页 函数数据透视表是什么 Linux开始菜单的编辑和配置

Linux开始菜单的编辑和配置

2023-09-29 11:41| 来源: 网络整理| 查看: 265

http://hotthing.blog.163.com/blog/static/2967030920085196153624/

相关配置文件:

/usr/share/applications目录中的 *.desktop文件

相关目录:

$HOME/.config/menus

/etc/xdg/menus

/usr/share/desktop-directories

修改后一般要更新数据库:

updatedb, update-desktop-database

update-desktop-database和update-desktop-*系列程序都位于xdg-utils 包中

--------------------------------------------------------------------------------------------------------------------------

qt4-qtconfig位于System-Administration,现在要把它更改到Applications-->Programming菜单下面:

更改(vim /usr/share/applications/qt4-qtconfig.desktop)其中的

Categories=Qt;Settings;为 Categories=Qt;Development;

为何不是Categories=Qt;Programming;呢?

切换到/usr/share/desktop-directories目录下面:

[root@localhost desktop-directories]# grep Programming *

Development.directory:Name=Programming

Development.directory:Name[en_CA]=Programming

Development.directory:Name[en_GB]=Programming

Development-More.directory:Name=More Programming Tools

Development-More.directory:Name[en_GB]=More Programming Tools

打开Development.directory文件,开头如下

[Desktop Entry]

Name=Programming

....................

说明Categories=Development在菜单中对应的就是Programming菜单目录。

最后,Categories=Qt;Development;同样可以写成Categories=Development;

如果想在Applications菜单项中添加一个新的菜单目录,可以通过添加/etc/xdg/menus目录中的条目来完成;

其中二级目录中的条目正好和桌面Applications中的条目相等。对于条目内容为空的,在Applications中将不会显示;比如在applications.menu文件中写有Education目录菜单,但是因为在/usr/share/applications目录下面列举的程序没有程序使用

Categories=Education;

所以,在Applications目录菜单中,没有Education子目录菜单。尝试修改任何一个.desktop文件(qt4- qtconfig.desktop),把Categories改成Education,立刻就会在Applications目录菜单中显示出 Applications-->Education--->qt4 config

(rpm -qi xdg-utils-1.0.2-2.fc8)The following scripts are provided at this time:

* xdg-desktop-menu      Install desktop menu items

* xdg-desktop-icon      Install icons to the desktop

* xdg-icon-resource     Install icon resources

* xdg-mime              Query information about file type handling and

                        install descriptions for new file types

* xdg-open              Open a file or URL in the user's preferred application

* xdg-email             Send mail using the user's preferred e-mail composer

* xdg-screensaver       Control the screensaver

===========================================

[root@localhost menus]# pwd

/etc/xdg/menus

[root@localhost menus]# ll

total 60

-rw-r--r-- 1 root root 12282 Dec 6 16:01 applications.menu

drwxr-xr-x 2 root root 4096 Nov 9 17:16 applications-merged

-rw-r--r-- 1 root root   488 Jul 6 16:58 gnome-screensavers.menu

-rw-r--r-- 1 root root   279 Sep 10 2005 kde-information.menu

-rw-r--r-- 1 root root   288 Sep 10 2005 kde-screensavers.menu

-rw-r--r-- 1 root root 2198 Aug 10 15:03 kde-settings.menu

-rw-r--r-- 1 root root 3020 Oct 19 23:53 preferences.menu

drwxr-xr-x 2 root root 4096 Oct 19 23:53 preferences-merged

drwxr-xr-x 2 root root 4096 Nov 9 17:19 preferences-post-merged

-rw-r--r-- 1 root root 1241 Oct 19 23:53 server-settings.menu

-rw-r--r-- 1 root root 1127 Oct 19 23:53 settings.menu

-rw-r--r-- 1 root root   920 Oct 19 23:53 start-here.menu

-rw-r--r-- 1 root root 3294 Oct 19 23:53 system-settings.menu

applications.menu文件可以设置在菜单项中是否包含某个菜单项,甚至可以exclude.

疑问).desktop文件所执行程序的查询路径是什么?

答:执行程序时路径设置在PATH环境变量中,.desktop文件通过其中的exec来指定要执行的应用程序,并在PATH所定义的路径中查找相应的应用程序。可以通过如下方式查看:

[root@localhost ~]# echo $PATH

/usr/lib/qt-3.3/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/lib/ccache:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin

疑问).desktop文件是如何执行”可执行应用程序“的?

答:可以先看一个简单的.desktop文件内容:

[root@localhost ~]# cat /usr/share/applications/amule.desktop

[Desktop Entry]

Encoding=UTF-8

//编码方式

Name=aMule

//应用程序名称,

Comment=aMule

//鼠标经过上面时的提示名称

Exec=amule

//可执行应用程序的实际名称

Icon=amule.png

//显示在菜单项中的图标,可以为空

Terminal=false

//是否使用终端

Type=Application

//分类

Categories=Application;Network; //分类

.desktop文件通过上述Exec=amule知道了应用程序的名称,并且区分大小写,并在PATH环境变量所默认设定的路径中查找,查找到即可执行,查找不到则报错,除非用户自己在PATH中设定了此应用程序所处的特殊路径。

=====================================================================

 Tip 

For detailed information describing the implementation of the menu system, refer to the Desktop Menu Specification located at the freedesktop.org website: http://standards.freedesktop.org/menu-spec/latest.

It is often useful for an administrator to add or remove items from the main desktop Applications menu. Owing to the complexity of the menu system, modifying the Applications menu can sometimes be a difficult task. For example, it is much more difficult to add a menu item than it is to remove a menu item.

This chapter provides an overview of the menu system and documents methods for:

Removing menu items for individual users

Removing menu items for all users

Removing submenus for individual users

Removing submenus for all users

http://www.freedesktop.org

The Red Hat menu system is based on the the freedesktop.org Desktop Menu Specification and consists of three major sets of configuration and data files:

Menu ( *.menu) Files

The *.menu files are XML configuration files that specify the order, hierarchy, and merging of both menus and menu items.

The system *.menu files are located in /etc/xdg/menus/. User-specific *.menu files are located in $HOME/.config/menus/ and can be edited to override the values specified in the system *.menu files.

In particular, the /etc/xdg/menus/applications.menu file contains the definition of the main application menu layout.

Directory Entry  (*.directory) Files

The *.directory files provide data about a menu such as its name, tooltip, and icon, and are located in /usr/share/desktop-directories/. Refer to the GNOME Desktop System Administration Guide for more information on directory entry files.

Desktop Entry ( *.desktop) Files

The *.desktop files provide data about a menu item such as its name, command to run, and its icon. The desktop entry files also contain keywords that determine the location of the menu item in the menu hierarchy. The system desktop entry files are located in /usr/share/applications/. Refer to the GNOME Desktop System Administration Guide for more information on desktop entry files.

User-specific desktop entry files are located in $HOME/.local/share/applications/ and can be used to add applications to the "Open With =>" submenu that appears when right-clicking on a file. The $HOME/.local/share/applications/mimeinfo.cache contains MIME type information associating the $HOME/.local/share/applications/*.desktop applications with the file types specified in the *.desktop files.

3.2. Removing Menu Items for Individual Users

The menu configuration files for a given user are located in the $HOME/.config/menus/ directory. The *.menu files are XML configuration files that allow you to override the system menu defaults.

For example, to remove the Calculator menu item from the Accessories submenu, edit theapplications.menu file in the $HOME/.config/menus/ directory, adding a new section using the element as shown:

Applications

/etc/xdg/menus/applications.menu

Accessories

gnome-gcalctool.desktop

The *.desktop file that corresponds to a given menu item can be found in the/usr/share/applications/ directory. The gnome-gcalctool.desktop file corresponds to the Calculator menu item. Note that the name of the submenu (Accessories, in this case) can be determined from the files located in the /usr/share/desktop-directories/ directory.

Similar methods can be used to remove other items from the Applications menu and its submenus.

Linux桌面菜单的编辑和配置 - hotthing - 豪星的博客Note 

The user's session must be restarted for the menu changes to take effect.

3.3. Removing Submenus for Individual Users

To remove the entire System Settings submenu for a user, use the element in the user's$HOME/.config/menus/applications.menu file as shown:

Applications

/etc/xdg/menus/applications.menu

System Settings

The other submenus of the Applications can be removed in similar fashion. Note that the name of the submenus can be determined from the files located in the /usr/share/desktop-directories/ directory.

3.4. Removing Menu Items for All Users

To remove the Dasher menu item from the Accessories submenu, edit/etc/xdg/menus/applications.menu, by adding the following before the final tag in the file:

...

Accessories

gnome-dasher.desktop

As mentioned above, the appropriate *.desktop file name to use for a given menu item can be determined from the files located in the /usr/share/applications/ directory.

3.5. Removing System Menus for All Users

To remove the System Settings submenu of the Applications menu, edit/etc/xdg/menus/applications.menu, by adding the following before the final tag in the file:

...

System Settings

The other submenus of the Applications can be removed in similar fashion. Note that the name of the submenus can be determined from the files located in the /usr/share/desktop-directories/ directory.

另:开始菜单修改:

方法一:直接在Ubuntu终端输入命令alacarte。可以任意增、改、隐藏、显示菜单,但无法删除菜单,即使拥有root权限。  方法二:注意几个目录和文件。 /usr/share/applications/下的desktop文件  /usr/share/applications/mimeinfo.cache文件  ~/.local/share/applications下的desktop文件 ~/.local/share/applications/default.list目录下的文件  ~/.local/share/applications/mimeinfo.cache文件  /etc/gnome/defaults.list文件 其中default.list文件保存的是文件的打开方式,比如txt文档用什么程序打开之类。 自然/etc下的是全局的文件打开方式,.local下的是个人的文件打开方式。  desktop文件是菜单项,就是出现在Application、System下的菜单项。 /usr下的是全局的菜单项,.local下的是个人的菜单项。 cache文件 ..

参考文章二:

Linux下配置Gnome的文件打开方式 & 开始菜单管理

http://www.verydemo.com/demo_c167_i75256.html

和Windows一样,在Gnome的文件管理器(nautilus)里,双击一个文件的时候, 系统会自动调用相应的程序去打开这个文件。前提是能打开这个文件的软件已经安装 并且配置完毕了。 在Nautilus里通过右键菜单固然可以修改默认的打开方式,但是缺乏灵活性和可 操作性,比如,不能删除一些候选的打开方式,不能批量增加一些打开方式等等。 经过反复的摸索,终于被我发现了GNMOE的打开方式的配置方式。 这里需要涉及到以下几个目录和文件 ~/.local/share/applications /etc/gnome/defaults.list /usr/share/applications /usr/share/applications/mimeinfo.cache ~/.local/share/applications/mimeinfo.cache 去这几个目录看一下,就会发现很多以 desktop 为后缀的文件。 这些文件是多功能的,第一,它们是组成GNMOE的“开始”菜单的一部分,即“开始” 菜单里的一些应用程序项,在这里都能找到。你可以运行 alacarte , 这里会 列出整个菜单的结构,你可以编辑它,但是很多项你没法删除,因为没有权限, 你试着用root权限去运行 alacarte ,抱歉,你还是没有权限删除,要删除它们, 只有在/usr/share/applications下面找到对应的文件,直接删除这个文件即可。 从总体上讲 /etc/gnome/defaults.list 保存了全局的打开方式 ~/.local/share/applications/defaults.list 保存了个人的打开方式 当两着不一致是,优先采用局部的个人设置。 ~/.local/share/applications /usr/share/applications 这两个分别是局部的desktop项和全局的desktop项 /usr/share/applications/mimeinfo.cache ~/.local/share/applications/mimeinfo.cache 这两个分别是全局的和局部的打开方式缓存 先看一下/etc/gnome/defaults.list的结构 [Default Applications] application/csv=gnumeric.desktop application/excel=ooo-calc.desktop application/msexcel=ooo-calc.desktop application/msword=ooo-writer.desktop application/ogg=mplayer.desktop application/pdf=evince.desktop application/postscript=evince.desktop ................. text/x-chdr=vim.desktop text/x-csrc=vim.desktop text/x-dtd=vim.desktop text/x-java=vim.desktop text/mathml=vim.desktop text/x-python=vim.desktop text/x-sql=vim.desktop text/xml=firefox.desktop video/dv=mplayer.desktop video/mp4=mplayer.desktop video/mpeg=mplayer.desktop video/msvideo=mplayer.desktop video/quicktime=mplayer.desktop video/vnd.rn-realvideo=mplayer.desktop video/x-anim=mplayer.desktop video/x-avi=mplayer.desktop video/x-flc=mplayer.desktop ...................... 不难发现 是这样的一种形式 程序的类型/文件类型=打开这个文件的项[;项2]...[;项n] 候选打开方式可以有好几种 中间用;隔开,不留其余字符 要修改一个文件的打开方式,需要先确定这个文件的类型 以纯文本文件为例 类型是plain 打开方式默认为vim.desktop 候选的是firefox.desktop text/plain=vim.desktop;firefox.desktop 可以直接编辑 ~/.local/share/applications/defaults.list /etc/gnome/defaults.list 编辑完之后,手工修改 /usr/share/applications/mimeinfo.cache ~/.local/share/applications/mimeinfo.cache 这两个cache文件。 这样就立即生效了 下面看一下desktop文件的结构 [Desktop Entry] Encoding=UTF-8 //字符编码 Name=vim  //现实的名字 MimeType=text/plain; //类型 Exec=vim %f //运行的程序 %f表示一个参数 Type=Application //类型 Terminal=true //是否使用终端 NoDisplay=true //是否显示在gnome菜单里 知道这些 就可以很方便的定制“开始”菜单 和 文件的打开方式了

参考文章三:

inux下菜单编辑配置

http://blog.csdn.net/jiangxinyu/article/details/1707453

"Linux下菜单编辑配置,文件打开方式,开始菜单管理" KDE,GNOME等桌面环境都支持 desktop快捷方式 在Gnome环境,与之相关的目录和文件有 ~/.local/share/applications 用户自己的应用程序快捷方式 /etc/gnome/defaults.list 系统 程序打开方式(我没有这个文件) /usr/share/applications  /usr/share/applications/mimeinfo.cache ~/.local/share/applications/mimeinfo.cache /etc/gnome-vfs-2.0 /usr/share/desktop-directories /usr/share/desktop-base /etc/gnome/defaults.list 保存了全局的打开方式 ~/.local/share/applications/defaults.list 保存了个人的打开方式 ~/.local/share/applications /usr/share/applications 这两个分别是局部的desktop项和全局的desktop项 /usr/share/applications/mimeinfo.cache ~/.local/share/applications/mimeinfo.cache 这两个分别是全局的和局部的打开方式缓存

desktop文件的结构 [Desktop Entry] Encoding=UTF-8 //字符编码 Name=vim   //显示的名字 MimeType=text/plain; //类型 Exec=vim %f //运行的程序 %f表示一个参数 Type=Application  //类型 Terminal=true //是否使用终端 NoDisplay=true //是否显示在gnome菜单里

GNome用这个  /etc/X11/desktop-menus/applications.menu XML文件来定义菜单的 它引用在 /usr/share/desktop-menu-files(旧版) /usr/share/applications(新版) 目录下的 .desktop文件 目录结构

< VFolderInfo> < MergeDir>< /MergeDir> < DesktopDir>< /DesktopDir> < Folder> < Name>Foo< /Name> < Desktop>Foobar.directory< /Desktop> < Query> < And> < Keyword>Category< /Keyword> < Not> < Keyword>Category< /Keyword> < /Not> < /And> < Include>appname.desktop< /Include> < Exclude>appname2.desktop< /Exclude> < Folder> ... < /Folder> < /Folder> < /VFolderInfo> "Re:Linux下菜单编辑配置,文件打开方式,开始菜单管理" (我在此将 菜单栏里面的 其他 以及其它里面的子目录以外的菜单栏 通称为一级目录,比如图像,互联网都是一级目录。) 和gnome菜单显示相关的有三个个目录:/usr/share/applications, /usr/share/gnome/apps和 /etc/X11/applnk/ 对于前者即/usr/share/applications里面都是 以desktop为后缀的文档;对于后者/usr/share/gnome/apps和/etc/X11/applnk/里面是一些目录,它们可以是 Network, Office, Graphics, AudioVideo, System, Development, Utility, Settings等 一般在这些目录里面也是以desktop为结尾的文件这些文件对应的菜单项一般是让它们在其它里面显示(我想也应该可以在第一级目录里面显示,呵呵没有试过).对于/usr/share/applications里面的文件,既可在其它里面显示也可在第一级菜单里面显示。 下面来看一下以.desktop结尾的文件的格式,低下是一个模板: [Desktop Entry] Name= Name[zh_CN]= Exec= Icon= Terminal= Type= Categories=Application;;; Encoding=UTF-8 Comment= Comment[zh_CN]= OnlyShowIn= X-Desktop-File-Install-Version=0.3 对上面的每一项我逐一解释: Name--你原意给程序取的名字 Name[zh_CN]--程序对应local为中文是的名字 Exec要执行的应用程序路径 Icon你想要显示的图标路径 Type程序的种类,一般为Application即可。 下面的Categories是关键,注意上面的几个分号,第一个之前一般为Application即可 第二个之前可以为Network, Office, Graphics, AudioVideo, System, Development, Utility, Settings 之一。 它们分别对应如下: 互联网 Network 办公 Office 图像 Graphics 声音和视频 AudioVideo 系统工具 System 编程 Development 辅助选项 Utility 首选项 Settings。 也就是说如果这一项是Network就会在互联网栏里面显示,这一项是Utility,你创建的菜单项就会在辅助选项里面显示,如此类推。 第二个分号之后的内容可以为X-Red-Hat-Base加X-Red-Hat-Base-Only或者X-Red-Hat-Extra。(注意只要加了X-Red-Hat-Base就不会在其他里面显示了)对于 X-Red-Hat-Base加X-Red-Hat-Base-Only 将在一级菜单里面显示,对于X-Red-Hat-Extra将在其它里面显示。 下面看我的两个个实例: [Desktop Entry] Name=redoffice Name[zh_CN]=红色办公Office Exec=redoffice Icon=/usr/share/pixmaps/redhat-word-processor.png Terminal=false Type=Application Categories=Application;Office;X-Red-Hat-Extra; Encoding=UTF-8 Comment=RedOffice1.2 Comment[zh_CN]=Office工具 X-Desktop-File-Install-Version=0.3 将在 其他 的 办公 里面显示我的菜单. [Desktop Entry] Name=redoffice Name[zh_CN]=红色办公Office Exec=redoffice Icon=/usr/share/pixmaps/redhat-word-processor.png Terminal=false Type=Application Categories=Application;Office;X-Red-Hat-Base;X-Red-Hat-Base-Only; Encoding=UTF-8 Comment=RedOffice1.2 Comment[zh_CN]=Office工具 X-Desktop-File-Install-Version=0.3 将在第一级菜单  办公[/b ]里面显示我的菜单 如下的几个是编码和说明以及是否在终端运行。OnlyShowIn指的是在kde里面还是gnome里面显示其值为GNOME或KDE 另外kde里面的菜单和/usr/share/applnk/的文件有关当然对应有[Kde Desktop Entry]我是用的gnome,没有试KDE. "Re:Linux下菜单编辑配置,文件打开方式,开始菜单管理" 让你自定义的子菜单与系统菜单平起平坐: 1.用文本编辑器打开 /etc/xdg/menus/applications.menu文件 2.添加如下内容:

(是不是很像网页源代码? Twisted Evil 不会做网页? Question 当我没说!) 3.用文本编辑器打开/usr/share/desktop-directories/下任意一个扩展名为.directory的文件,另存为esito.directory. 4.修改esito.directory文件: [Desktop Entry] Name=esITo Name[zh_CN]=esITo自定义菜单 Comment=esITo菜单 Comment[zh_CN]=esITo自定义菜单 Icon=emacs.png Type=Directory 注: Name=esITo 英文名字 必需 esITo Name[zh_CN]=esITo 中文名字 除非你用英文 Comment=esITo menu 英文注释 Comment[zh_CN]=esITo自定义菜单 中文注释 Icon=emacs.png 菜单的图标 自己到/usr/share/pixmaps目录里选 Type=Directory 表示是文件夹 必需 5.用文本编辑器打开一个/usr/share/applications目录中的快捷方式(随意),修改Categories项为Categories=esITo 6.重新起动X系统(RedHat/Fedora Core基本上需要重启Linux了) 7.其中esITo是我自己起的名字,可以为任意英文标识. 8.当你没有设置任何快捷方式到你的菜单项里时,你的菜单项是不会显示的!

"Re:Linux下菜单编辑配置,文件打开方式,开始菜单管理" $XDG_CONFIG_DIRS/menus/applications.menu /etc/xdg ~/.config/ ======================== /etc/xdg/menus/gnome-applications.menu ~/.config/menus/gnome-applications.menu 修改这里,就可以了



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有