Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| zh-cn:howto:customize-menu [2012/04/18 17:30] – [Create sub-menus] haobug | zh-cn:howto:customize-menu [2026/11/06 04:12] (current) – removed kevinbowen | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== 自定义 Xfce 菜单 ====== | ||
| - | |||
| - | 此页介绍如何在4.5或更高版本 Xfdesktop 上自定义菜单。对于早期版本,您可以使用 libxfce4menu 的 GUI。 | ||
| - | |||
| - | GNU 许可的 LXDE 的图形菜单编辑器 | ||
| - | ===== xfdesktop 会安装什么文件 ===== | ||
| - | Xfdesktop 会安装菜单文件和 .desktop 文件以及一些定义菜单的非 xfdesktop 的 .desktop 文件。自定义菜单就需要修改这些文件。这里描述修改的菜单文件由环境变量 $XDG_CONFIG_HOME 确定(通常为空,所以是 ~/ | ||
| - | |||
| - | ===== 你的修改什么时候生效 ==== | ||
| - | 当 xfdesktop 会话启动时,如果菜单文件的目录存在,修改立即生效。同样地,当 xfdesktop 会话启动时,如果你主目录中的 // | ||
| - | ===== 复制菜单文件 ===== | ||
| - | |||
| - | 只有你想要修改硬编码的项(通常在“设置”菜单以上,及最后一个子菜单以下)或者说你需要修改子菜单的定义时才需要这样做。 | ||
| - | |||
| - | 创建 ~/ | ||
| - | |||
| - | mkdir ${XDG_CONFIG_HOME: | ||
| - | |||
| - | 复制已安装的菜单文件到先于默认安装的菜单文件路径的 xfdesktop 查找的路径中(在大多数系统上 $prefix = /usr)。 | ||
| - | cp $prefix/ | ||
| - | 或者 | ||
| - | cp $prefix/ | ||
| - | |||
| - | ===== 复制 .desktop 文件 ===== | ||
| - | |||
| - | 例如,要复制Web浏览器的 .desktop 文件到主目录中的 // | ||
| - | (在大多数系统上 $prefix = /usr): | ||
| - | |||
| - | cp $prefix/ | ||
| - | 或者 | ||
| - | cp / | ||
| - | ===== 隐藏菜单项 ===== | ||
| - | |||
| - | 如果你想隐藏菜单项,复制他的 .desktop 文件,编辑并添加一行 '' | ||
| - | |||
| - | |||
| - | >> {{wiki: | ||
| - | >> 如[[http:// | ||
| - | |||
| - | ===== 只隐藏根菜单项 ===== | ||
| - | |||
| - | 如果你只想删除根菜单项,复制它们的 .desktop 文件,编辑并删除 X-Xfce-Toplevel Category。 | ||
| - | |||
| - | Xfdesktop 默认会安装下面这些根菜单项(在大多数系统上 $prefix = /usr): | ||
| - | |||
| - | * '' | ||
| - | * '' | ||
| - | * '' | ||
| - | * '' | ||
| - | * '' | ||
| - | * '' | ||
| - | * '' | ||
| - | |||
| - | 例如,把Web浏览器从根菜单中删除,复制它的 .desktop 文件,编辑并修改 '' | ||
| - | |||
| - | ===== 添加菜单项 ===== | ||
| - | |||
| - | 为每个菜单项创建一个 .desktop。例如,一个 Eclipse 的菜单项,在 '' | ||
| - | [Desktop Entry] | ||
| - | Version=1.0 | ||
| - | Type=Application | ||
| - | Encoding=UTF-8 | ||
| - | Exec=eclipse | ||
| - | Icon=eclipse | ||
| - | StartupNotify=false | ||
| - | Categories=X-XFCE; | ||
| - | OnlyShowIn=XFCE; | ||
| - | Name=Eclipse | ||
| - | Comment=Eclipse Java IDE | ||
| - | |||
| - | 如果你喜欢用 GUI 工具(可以浏览选择图标),你可以用下面的命令创建 .desktop 文件 | ||
| - | |||
| - | exo-desktop-item-edit --create-new ~/ | ||
| - | |||
| - | 但这样新建的文件类别(Category)里面只有 Application, | ||
| - | |||
| - | 类别(Category)决定菜单项会显示在哪。要在根菜单中显示,添加 X-Xfce-Toplevel 类别。要在子菜单中显示,添加至少一个已定义的子菜单类别。这个可以在 '' | ||
| - | <code xml> | ||
| - | < | ||
| - | < | ||
| - | < | ||
| - | < | ||
| - | <Or> | ||
| - | < | ||
| - | < | ||
| - | < | ||
| - | < | ||
| - | </Or> | ||
| - | </ | ||
| - | </ | ||
| - | </ | ||
| - | |||
| - | 任何包含 Accessibility, Core, Legacy 及 Utility 类别的并没有 '' | ||
| - | |||
| - | ===== ”其他“ 子菜单 ===== | ||
| - | |||
| - | 如果有 .desktop 文件配置了要在菜单中显示,但没有任何已定义的类别(用于包含他们到已定义的菜单中),”其他“菜单就会显示这些菜单项。这条规则适用于 // | ||
| - | |||
| - | 如果你的系统有”其他“,但你不想要它,复制菜单项的 .desktop 文件,修改它的类别,使它被包含到其他子菜单中去。 | ||
| - | |||
| - | ===== 创建子菜单 ===== | ||
| - | 创建一个新的子菜单, | ||
| - | <code xml> | ||
| - | < | ||
| - | < | ||
| - | < | ||
| - | < | ||
| - | < | ||
| - | </ | ||
| - | </ | ||
| - | </ | ||
| - | |||
| - | 接下来,创建 ~/ | ||
| - | [Desktop Entry] | ||
| - | Version=1.0 | ||
| - | Type=Directory | ||
| - | Icon=file-manager | ||
| - | Name=Folders | ||
| - | Comment=Folders viewed in a file manager | ||
| - | |||
| - | 这提供了子目录的显示名字及合适的图标。 | ||
| - | |||
| - | 最后,在 | ||
| - | |||
| - | [Desktop Entry] | ||
| - | Version=1.0 | ||
| - | Type=Application | ||
| - | Exec=/ | ||
| - | Icon=file-manager | ||
| - | StartupNotify=false | ||
| - | Categories=X-Folders; | ||
| - | OnlyShowIn=XFCE | ||
| - | Name=home | ||
| - | Comment=home displayed in Thunar | ||
| - | |||
| - | 做完这些,你会发现多了一个叫 " | ||
| - | ===== 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 | ||
| - | If that doesn' | ||
| - | killall -HUP xfdesktop | ||
| - | |||
| - | ===== Questions ===== | ||
| - | ==== Answered ==== | ||
| - | |||
| - | **Question: | ||
| - | **Answer:** In Jaunty the appropriate file might be found in / | ||
| - | |||
| - | **Question: | ||
| - | **Answer:** Menu file changes are implemented immediately if the menu file's directory exists when the xfdesktop session starts. | ||
| - | |||
| - | **Question: | ||
| - | **Answer:** No. The menu file defines which categories of entry go where. Your further application will appear in the defined place(s). If not, compare its categories with the categories in the menu file and adjust accordingly. | ||
| - | |||
| - | ==== Unanswered ==== | ||
| - | * What do i do, if the above does //not// work? (only xfce's own desktop files are seen, not even the one created with exo-desktop-item-edit, | ||
| - | * Where do i find a log or anything like that, actually giving me a clue other than simply empty space in the menu? | ||
| - | * I run Jaunty and need to make the menu to be multi-level, | ||