Xfce Wiki

Sub domains
 

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
zh-cn:howto:customize-menu [2012/04/18 15:27] – [What xfdesktop installs] haobugzh-cn:howto:customize-menu [2012/04/18 17:44] – [”其他“ 子菜单] haobug
Line 8: Line 8:
 Xfdesktop 会安装菜单文件和 .desktop 文件以及一些定义菜单的非 xfdesktop 的 .desktop 文件。自定义菜单就需要修改这些文件。这里描述修改的菜单文件由环境变量 $XDG_CONFIG_HOME 确定(通常为空,所以是 ~/.config/menus/xfce-applications.menu)和一些你的主目录中 .desktop 文件。 Xfdesktop 会安装菜单文件和 .desktop 文件以及一些定义菜单的非 xfdesktop 的 .desktop 文件。自定义菜单就需要修改这些文件。这里描述修改的菜单文件由环境变量 $XDG_CONFIG_HOME 确定(通常为空,所以是 ~/.config/menus/xfce-applications.menu)和一些你的主目录中 .desktop 文件。
  
-===== When xfdesktop implements your changes ==== +===== 你的修改什么时候生效 ==== 
-If the menu file's directory exists when the xfdesktop session starts, changes to the menu file are implemented immediately.  Similarly if the //.local/share/applications// directory in your home directory exists when the xfdesktop session starts, changes to its .desktop files are implemented immediately.+当 xfdesktop 会话启动时,如果菜单文件的目录存在,修改立即生效。同样地,当 xfdesktop 会话启动时,如果你主目录中的 //.local/share/applications// 目录存在的话,对 .desktop 文件的修改也立即生效。 
 +===== 复制菜单文件 =====
  
-===== Copy the menu file ===== +只有你想要修改硬编码的项(通常在“设置”菜单以上,及最后一个子菜单以下)或者说你需要修改子菜单的定义时才需要这样做。 
-This is only necessary if you want to change the hardcoded entries (usually above the Settings sub-menu and below the last sub-menu) or to change the sub-menu definitions.+ 
 +创建 ~/.config/menus 目录(如果还不存在):
  
-Create ~/.config/menus directory (if it doesn't exist already): 
   mkdir ${XDG_CONFIG_HOME:-~/.config}/menus/   mkdir ${XDG_CONFIG_HOME:-~/.config}/menus/
-Copy the installed menu file to where xfdesktop will look for it before looking for the installed menu file ($prefix = /usr on most systems):+ 
 +复制已安装的菜单文件到先于默认安装的菜单文件路径的 xfdesktop 查找的路径中(在大多数系统上 $prefix = /usr)。
   cp $prefix/etc/xdg/menus/xfce-applications.menu ${XDG_CONFIG_HOME:-~/.config}/menus   cp $prefix/etc/xdg/menus/xfce-applications.menu ${XDG_CONFIG_HOME:-~/.config}/menus
-or+或者
   cp $prefix/etc/xfce/xdg/menus/xfce-applications.menu ${XDG_CONFIG_HOME:-~/.config}/menus   cp $prefix/etc/xfce/xdg/menus/xfce-applications.menu ${XDG_CONFIG_HOME:-~/.config}/menus
  
-===== Copy a .desktop file ===== +===== 复制 .desktop 文件 ===== 
-For example, to copy the Web Browser'.desktop file to the //.local/share/applications// directory in your home directory ($prefix = /usr on most systems):+ 
 +例如,要复制Web浏览器的 .desktop 文件到主目录中的 //.local/share/applications// 目录 
 +(在大多数系统上 $prefix = /usr): 
   cp $prefix/share/applications/xfce4-web-browser.desktop ~/.local/share/applications    cp $prefix/share/applications/xfce4-web-browser.desktop ~/.local/share/applications 
-or+或者
   cp /usr/share/applications/xfce4-web-browser.desktop ~/.local/share/applications   cp /usr/share/applications/xfce4-web-browser.desktop ~/.local/share/applications
-===== Hide menu entries ===== +===== 隐藏菜单项 ===== 
-If you want to hide menu entries from all menus, copy their .desktop files and edit them to add a ''NoDisplay=true'' line.+ 
 +如果你想隐藏菜单项,复制他的 .desktop 文件,编辑并添加一行 ''NoDisplay=true'' 。 
  
 >> {{wiki:warning.png}} >> {{wiki:warning.png}}
->> As explained[[http://standards.freedesktop.org/desktop-entry-spec/latest/ar01s05.html|here]]''NoDisplay=true'' will hide the application from the menu but the mime type associations will still be available. ''Hidden=true'' is equivalent to deleting the file.+>> [[http://standards.freedesktop.org/desktop-entry-spec/latest/ar01s05.html|]]的解释,''NoDisplay=true'' 会在菜单上隐藏程序,但 mime 类型的关联仍然存在。''Hidden=true'' 等价于删除这个文件。
  
-===== Hide only root entries ===== +===== 只隐藏根菜单项 =====
-If you only want to remove menu items from the root menu only, copy their .desktop files and edit them to remove Category X-Xfce-Toplevel.+
  
-Xfdesktop installs the following desktop entry files in the root menu ($prefix = /usr on most systems):+如果你只想删除根菜单项,复制它们的 .desktop 文件,编辑并删除 X-Xfce-Toplevel Category。 
 + 
 +Xfdesktop 默认会安装下面这些根菜单项(在大多数系统上 $prefix = /usr):
  
   * ''$prefix/share/applications/xfce4-about-xfce.desktop''   * ''$prefix/share/applications/xfce4-about-xfce.desktop''
Line 45: Line 53:
   * ''$prefix/share/applications/xfce4-web-browser.desktop''   * ''$prefix/share/applications/xfce4-web-browser.desktop''
  
-For example, to remove Web Browser from the root menu, copy its .desktop file and edit it, changing ''Categories=X-XFCE;X-Xfce-Toplevel;'' to ''Categories=X-XFCE;''+例如,把Web浏览器从根菜单中删除,复制它的 .desktop 文件,编辑并修改 ''Categories=X-XFCE;X-Xfce-Toplevel;'' 为 ''Categories=X-XFCE;'' 
 + 
 +===== 添加菜单项 =====
  
-===== Add entries ===== +为每个菜单项创建一个 .desktop。例如,一个 Eclipse 的菜单项,在 ''~/.local/share/applications''中创建文件 ''eclipse.desktop''
-Create a .desktop file for each entry required.  For example, a menu entry for Eclipse, create a file named ''eclipse.desktop'' in ''~/.local/share/applications'':+
   [Desktop Entry]   [Desktop Entry]
   Version=1.0   Version=1.0
Line 60: Line 69:
   Name=Eclipse   Name=Eclipse
   Comment=Eclipse Java IDE   Comment=Eclipse Java IDE
-If you prefer to work in a GUI (allows browsing for the icon) you can create the .desktop file using+ 
 +如果你喜欢用 GUI 工具(可以浏览选择图标),你可以用下面的命令创建 .desktop 文件 
   exo-desktop-item-edit --create-new ~/.local/share/applications   exo-desktop-item-edit --create-new ~/.local/share/applications
-but the new file will only have category Application so will probably need editing afterwards. 
  
-The categories determine where the new entry will be displayed. For display in the root menuinclude category X-Xfce-Toplevel.  For display in a sub-menu, include at least one of the categories defined for that sub-menu.  These can be found by examining your ''${XDG_CONFIG_HOME:-~/.config}/menus/xfce-applications.menu''. For example here's an Accessories sub-menu definition:+但这样新建的文件类别(Category)里面只有 Application可能需要再编辑才行。 
 + 
 +类别(Category)决定菜单项会显示在哪。要在根菜单中显示,添加 X-Xfce-Toplevel 类别。要在子菜单中显示,添加至少一个已定义的子菜单类别。这个可以在 ''${XDG_CONFIG_HOME:-~/.config}/menus/xfce-applications.menu'' 文件中找到。例如这是一个“附件”菜单的定义:
 <code xml> <code xml>
     <Menu>     <Menu>
Line 79: Line 91:
     </Menu>     </Menu>
 </code> </code>
-Any .desktop files with categories including Accessibility, Core, Legacy or Utility will be shown in the Accessories sub-menu providing they do not also have ''NoDisplay=true''. 
  
-===== The Other sub-menu ===== +任何包含 Accessibility, Core, Legacy 及 Utility 类别的并没有 ''NoDisplay=true'' 的  .desktop 文件都会显示在“附件”菜单下。
-If there are any .desktop files which are configured to be displayed in the xfdesktop menu but do not have any categories which include them in any of the defined menus, the Other sub-menu will be displayed and will display those entries.  This applies to .desktop files in the //$prefix/share/applications/// directory as well as the //~/.local/share/applications// directory.+
  
-If you have an Other sub-menu and do not want it, copy the .desktop file and modify its categories so it is included in one of the other sub-menus.+===== "其他" 子菜单 =====
  
-===== Create sub-menus ===== +如果有 .desktop 文件配置了要在菜单中显示,但没有任何已定义的类别(用于包含他们到已定义的菜单中),"其他"菜单就会显示这些菜单项。这条规则适用于 //$prefix/share/applications///和 //~/.local/share/applications//  中的 .desktop 文件。
-To create a new sub-menu, add a new "Menuelement to your ~/.config/menus/xfce-applications.menu at the same level as the other xfdesktop sub-menus like "Graphics" or "Multimedia". In addition to the aptly named "Name" element, two additional elements are required: first, the "Directory" element is useful to associate the submenu with a desktop entry file which provides, among others, an appropriate icon as we will see shortly. Second, the "Category" element associates .desktop files with this sub-menu. It is recommended to make up a custom category starting with "X-", which is the prefix of non-standard categories by convention. As an example, we'll create a submenu with entries to display various folders in your favourite file manager. Your new entry should look like this:+
  
 +如果你的系统有”其他“,但你不想要它,复制菜单项的 .desktop 文件,修改它的类别,使它被包含到其他子菜单中去。
 +
 +===== 创建子菜单 =====
 +创建一个新的子菜单,  添加一个 "Menu" 元素到 ~/.config/menus/xfce-applications.menu 到和其他 xfdesktop 子菜单(比如"图像","多媒体")相同的级别。再添加一个 "Name" 元素,及另外两个必须的元素:第一,"Directory" 元素,它对关联子菜单和 desktop 文件,及一个相应的合适的图标。. 第二,"Category" 元素,它关联 .desktop 文件和子菜单。建议自定义类别时使用"X-"开头,这是非标准的类别的前缀约定。例如,创建一个子菜单,用你喜欢的文件管理器打开不同的文件夹。新的菜单项,应该类似于下面这样:
 <code xml> <code xml>
   <Menu>   <Menu>
Line 99: Line 112:
 </code> </code>
  
-Next, create ~/.local/share/desktop-directories/folders.directory with the following contents: +接下来,创建 ~/.local/share/desktop-directories/folders.directory 文件,内容如下:
   [Desktop Entry]   [Desktop Entry]
   Version=1.0   Version=1.0
Line 108: Line 120:
   Comment=Folders viewed in a file manager   Comment=Folders viewed in a file manager
  
-This provides the displayed name of the subdirectory as well as an appropriate icon.+这提供了子目录的显示名字及合适的图标。
  
-Finally, create .desktop files in your ~/.local/share/applications folder as shown above to populate the submenuIn order to be displayed in the submenu, add your custom category to the "Categories" list. One of these files, let's call it thunar-home.desktop, might look like this:+最后,在  ~/.local/share/applications 文件夹中创建 .desktop 文件来构成子菜单。为了显示在子菜单中,添加自定义的类别到"Categories" 列表中。我们就把它命名为 thunar-home.desktop 它的内容类似于下面这样:
  
   [Desktop Entry]   [Desktop Entry]
Line 123: Line 135:
   Comment=home displayed in Thunar   Comment=home displayed in Thunar
  
-With all this in place, you should have a new submenu called "Folders" using the file manager icon. The submenu entry shown above should display your home directory in Thunar. You can of course add more entries as shortcuts to common places like /cdrom/stick/, or whatever you see fit.+做完这些,你会发现多了一个叫 "Folders" 的子菜单,图标为文件管理器的图标。这个菜单项,应该在 Thunar 里面显示你的主目录。当然,你可以添加更多的条目作为到常用的位置 /cdrom/stick/,以及其他你觉得可以的位置的快捷方式。 
 +===== 强制修改 ===== 
 + 
 +这通常没有必要并且不一定起作用;注销然后再进入才总是有用的。
  
-===== Forcing changes ===== +如果菜单没有自动更新,试一下
-This is not usually necessary and may not work anyway; logging out of the Xfce session and back in always works. +
  
-If the menu is not automatically updated with your changes, try 
   xfdesktop --reload   xfdesktop --reload
-If that doesn't work, try+如果没有超作用,再试一下
   killall -HUP xfdesktop   killall -HUP xfdesktop
  
-===== Questions =====+===== 问题 =====
 ==== Answered ==== ==== Answered ====