Xdg-menu: Difference between revisions
(添加中文) |
NetSysFire (talk | contribs) m (→See also: - expand link) |
||
(21 intermediate revisions by 7 users not shown) | |||
Line 1: | Line 1: | ||
{{Lowercase title}} | |||
[[Category:Freedesktop.org]] | [[Category:Freedesktop.org]] | ||
[[es:Xdg-menu]] | |||
[[ja:Xdg-menu]] | [[ja:Xdg-menu]] | ||
[[ru:Xdg-menu]] | [[ru:Xdg-menu]] | ||
[[zh-hans:Xdg-menu]] | [[zh-hans:Xdg-menu]] | ||
''xdg-menu'' is a tool that generates [https://specifications.freedesktop.org/menu-spec/menu-spec-latest.html XDG Desktop Menus] for the following [[window manager]]s: | |||
* [[awesome]] | * [[awesome]] | ||
Line 10: | Line 12: | ||
* [[FVWM2]] | * [[FVWM2]] | ||
* [[IceWM]] | * [[IceWM]] | ||
* [[Openbox]] | * [[Openbox]] | ||
* [[twm]] | * [[twm]] | ||
* [[Window Maker]] | * [[Window Maker]] | ||
KDE, | [[KDE]], [[GNOME]], [[Xfce]] and [[Enlightenment]] are already XDG compatible. | ||
== Installation == | == Installation == | ||
[[Install]] the {{ | [[Install]] the {{Pkg|archlinux-xdg-menu}} package. | ||
== Menu hierarchy == | == Menu hierarchy == | ||
* Applications | * Applications | ||
** Accessibility | ** Accessibility | ||
Line 38: | Line 40: | ||
== Configuration == | == Configuration == | ||
xdg_menu relies on three sets of information to generate menus: a root menu or in other words an XML menu template generally passed on the command line, information cached when it was last run, and a series of configuration files. | |||
* You can find some XML menu templates in {{ic|/etc/xdg/menus}}. | * You can find some XML menu templates in {{ic|/etc/xdg/menus}}. | ||
* If altering the code in xdg_menu to change layout, make sure you delete everything in {{ic|~/.xdg_menu_cache}} or you will spend hours trying to figure out why your changes to the perl script | * If altering the code in xdg_menu to change layout, make sure you delete everything in {{ic|~/.xdg_menu_cache}} or you will spend hours trying to figure out why your changes to the perl script do not take. | ||
* You can find individual application configurations in {{ic|/usr/share/applications}} | * You can find individual application configurations in {{ic|/usr/share/applications}}. | ||
Other configuration file directories can be found under {{ic|/usr/share}}. In most cases you will not need to touch these. However if you want to change how your menu is layed out you can alter the menu template for minor changes. Major changes require tweaking the actual xdg_menu perl script. If you find that applications do not appear or that they are called strange things, then you will need to look at the .desktop file in {{ic|/usr/share/applications}}. Check the [https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html desktop entry specification]. | Other configuration file directories can be found under {{ic|/usr/share}}. In most cases you will not need to touch these. However if you want to change how your menu is layed out you can alter the menu template for minor changes. Major changes require tweaking the actual xdg_menu perl script. If you find that applications do not appear or that they are called strange things, then you will need to look at the .desktop file in {{ic|/usr/share/applications}}. Check the [https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html desktop entry specification]. | ||
Line 66: | Line 68: | ||
=== xdg_menu === | === xdg_menu === | ||
{{bc| | |||
xdg_menu [--format <format>] [--desktop <desktop>] | xdg_menu [--format <format>] [--desktop <desktop>] | ||
[--charset <charset>] [--language <language>] | [--charset <charset>] [--language <language>] | ||
Line 99: | Line 101: | ||
help - print this text | help - print this text | ||
}} | |||
=== update-menus === | === update-menus === | ||
''update-menus'' updates WM's menus from XDG data and can be configured to do it automaticaly. | |||
This is a script wrapper around xdg_menu that relies on {{ic|/etc/update-menus.conf}} | This is a script wrapper around xdg_menu that relies on {{ic|/etc/update-menus.conf}} | ||
To use it, you need to install the {{Pkg|archlinux-xdg-menu}} package (xdg_menu) | |||
{{ic|/etc/update-menus.conf}} | In {{ic|/etc/update-menus.conf}}, you have to select from a list of window managers for which the menu should be generated. Comments with # are allowed. | ||
All generated menus placed in {{ic|/var/cache/xdg-menu/}}. See wm-specific Examples section of this page to get more information. | All generated menus are placed in {{ic|/var/cache/xdg-menu/}}. See wm-specific [[#Examples]] section of this page to get more information. | ||
== Examples == | == Examples == | ||
Line 118: | Line 120: | ||
==== With xdg_menu ==== | ==== With xdg_menu ==== | ||
Then edit your rc.lua as shown below | $ xdg_menu --format awesome --root-menu /etc/xdg/menus/arch-applications.menu > ~/.config/awesome/archmenu.lua | ||
* Add a require statment for your new menu.lua file | |||
* Add an entry to your awful.menu object for your new menu which calls | Then, edit your {{ic|rc.lua}} as shown below. | ||
* Add a require statment for your new {{ic|menu.lua}} file. | |||
* Add an entry to your {{ic|awful.menu}} object for your new menu which calls {{ic|xdg-menu}}. | |||
{{bc|1= | |||
... | ... | ||
xdg_menu = require("archmenu") | xdg_menu = require("archmenu") | ||
Line 137: | Line 140: | ||
}) | }) | ||
... | ... | ||
}} | |||
=== IceWM === | === IceWM === | ||
==== With xdg_menu ==== | ==== With xdg_menu ==== | ||
$ xdg_menu --format icewm --fullmenu --root-menu /etc/xdg/menus/arch-applications.menu >> ~/.icewm/programs | |||
-- | |||
==== With update-menus ==== | ==== With update-menus ==== | ||
* Uncomment | * Uncomment ''icewm'' in {{ic|/etc/update-menus.conf}}. | ||
* | * Run {{ic|update-menus}} as root. | ||
* | * Make a symlink to {{ic|/var/cache/xdg-menu/icewm/programs}} in {{ic|~/.icewm/programs}}. | ||
} | |||
. | |||
=== FluxBox === | === FluxBox === | ||
Line 212: | Line 158: | ||
==== With xdg_menu ==== | ==== With xdg_menu ==== | ||
$ xdg_menu --format fluxbox --root-menu /etc/xdg/menus/arch-applications.menu > ~/.fluxbox/my-menu | |||
$ xdg_menu --format fluxbox | |||
Change your menu file to include generated menu. | Change your menu file to include the generated menu. | ||
For example add line: | For example, add this line: | ||
[include] (my-menu) | |||
==== With update-menus ==== | ==== With update-menus ==== | ||
* Uncomment fluxbox in /etc/update-menus.conf | * Uncomment ''fluxbox'' in {{ic|/etc/update-menus.conf}}. | ||
* | * Run {{ic|update-menus}} as root. | ||
* | * Change your menu file to include generated menu. | ||
For example add line: | For example, add this line: | ||
[include] (/var/cache/xdg-menu/fluxbox/boxrc) | |||
=== OpenBox === | === OpenBox === | ||
Line 240: | Line 180: | ||
==== With xdg_menu ==== | ==== With xdg_menu ==== | ||
Generate menu with | Generate menu with: | ||
$ xdg_menu --format openbox3 --root-menu /etc/xdg/menus/arch-applications.menu > xdg-menu.xml | |||
And manually add it into your {{ic|menu.xml}}. For example, put {{ic|xdg-menu.xml}} into {{ic|menu.xml}} and add: | |||
<menu id="Applications" /> | |||
Into {{ic|root-menu}}. | |||
==== As a pipe menu ==== | ==== As a pipe menu ==== | ||
Line 257: | Line 194: | ||
Using xdg_open as a pipe menu gives you the added benefit of having a menu that automatically updates when you install new applications. | Using xdg_open as a pipe menu gives you the added benefit of having a menu that automatically updates when you install new applications. | ||
Add the following somewhere inside your menu.xml between your root menu tags | Add the following somewhere inside your menu.xml between your root menu tags: | ||
<menu id="applications" label="Applications" execute="xdg_menu --format openbox3-pipe --root-menu /etc/xdg/menus/arch-applications.menu" / | <menu id="applications" label="Applications" execute="xdg_menu --format openbox3-pipe --root-menu /etc/xdg/menus/arch-applications.menu" /> | ||
A very basic example: | A very basic example: | ||
< | |||
{{bc|<nowiki> | |||
<?xml version="1.0" encoding="UTF-8"?> | <?xml version="1.0" encoding="UTF-8"?> | ||
Line 279: | Line 216: | ||
</openbox_menu> | </openbox_menu> | ||
</ | </nowiki>}} | ||
==== With update-menus ==== | ==== With update-menus ==== | ||
* Uncomment openbox in /etc/update-menus.conf | |||
* | * Uncomment ''openbox'' in {{ic|/etc/update-menus.conf}}. | ||
* | * Run {{ic|update-menus}} as root. | ||
* Change your {{ic|menu.xml}} file to include generated menu. | |||
For example, add following to root-menu: | For example, add following to root-menu: | ||
<menu id="xdg-menu" label="XDG Menu" execute="cat /var/cache/xdg-menu/openbox/menu.xml"/ | <menu id="xdg-menu" label="XDG Menu" execute="cat /var/cache/xdg-menu/openbox/menu.xml"/> | ||
=== Twm === | === Twm === | ||
Line 295: | Line 232: | ||
==== With xdg_menu ==== | ==== With xdg_menu ==== | ||
Use | Use: | ||
$ xdg_menu --format twm --root-menu /etc/xdg/menus/arch-applications.menu >my-twm-menu | |||
And add it into twmrc manually. In the case of twm derivatives with m4 preprocessing such as vtwm or ctwm it can be included by adding: | |||
sinclude(`/PATH/TO/my-twm-menu') | |||
To {{ic|*twmrc}}. | |||
==== With update-menus ==== | ==== With update-menus ==== | ||
* Uncomment twm in /etc/update-menus.conf | * Uncomment ''twm'' in {{ic|/etc/update-menus.conf}}. | ||
* Add | * Add in {{ic|/etc/X11/twm/system.twmrc}} a file applications menu (add it into {{ic|defops menu}}): | ||
"apps" f.menu "Applications" | "apps" f.menu "Applications" | ||
* Run {{ic|update-menus}} as root. | |||
* Run {{ic|twm -f /var/cache/xdg-menu/twm/twmrc}}. | |||
{{Tip|You will also want to add your other customizations to {{ic|/etc/X11/twm/system.twmrc}}.}} | |||
=== WindowMaker === | === WindowMaker === | ||
Line 323: | Line 258: | ||
==== With xdg_menu ==== | ==== With xdg_menu ==== | ||
Use | Use: | ||
$ xdg_menu --format WindowMaker --root-menu /etc/xdg/menus/arch-applications.menu >my-wm-menu | |||
And add: | |||
#include "my-wm-menu" | |||
Into your WindowMaker menu file. | |||
You can also use the WPrefs "Application Menu Definitions", and add the xdg command as a parameter in a "Generated Submenu" object. | You can also use the WPrefs "Application Menu Definitions", and add the xdg command as a parameter in a "Generated Submenu" object. | ||
==== With update-menus ==== | ==== With update-menus ==== | ||
* Uncomment ''WindowMaker'' in {{ic|/etc/update-menus.conf}}. | |||
* Run {{ic|update-menus}} as root. | |||
* Add: | |||
#include "/var/cache/xdg-menu/WindowMaker/wmrc" | |||
Into your menu file. | |||
=== Fvwm2 === | === Fvwm2 === | ||
Line 353: | Line 284: | ||
==== With xdg_menu ==== | ==== With xdg_menu ==== | ||
Generate menu | Generate the menu: | ||
$ xdg_menu --format fvwm2 --root-menu /etc/xdg/menus/arch-applications.menu >fvwm2-menu | |||
$ xdg_menu --format fvwm2 --root-menu /etc/xdg/menus/arch-applications.menu >fvwm2-menu | |||
And add it into the root menu: | |||
{{bc| | |||
read fvwm2-menu | read fvwm2-menu | ||
AddToMenu MenuFvwmRoot "Root Menu" Title | AddToMenu MenuFvwmRoot "Root Menu" Title | ||
+ "&0. XDG Menu" Popup xdg_menu | + "&0. XDG Menu" Popup xdg_menu | ||
}} | |||
==== With update-menus ==== | ==== With update-menus ==== | ||
* Uncomment fvwm2 in /etc/update-menus.conf | * Uncomment ''fvwm2'' in {{ic|/etc/update-menus.conf}}. | ||
* | * Run {{ic|update-menus}} as root. | ||
* | * Change your {{ic|.fvwm2rc}} file to include generated menu. For example: | ||
AddToMenu MenuFvwmRoot "Root Menu" Title | |||
AddToMenu MenuFvwmRoot "Root Menu" Title | + "&0. XDG Menu" Popup xdg_menu | ||
+ "&0. XDG Menu" Popup xdg_menu | |||
read /var/cache/xdg-menu/fvwm2/fvwm2rc | |||
read /var/cache/xdg-menu/fvwm2/fvwm2rc | |||
=== BlackBox === | === BlackBox === | ||
Line 387: | Line 312: | ||
==== With xdg_menu ==== | ==== With xdg_menu ==== | ||
$ xdg_menu --format blackbox --root-menu /etc/xdg/menus/arch-applications.menu >my-menu | |||
$ xdg_menu --format blackbox --root-menu /etc/xdg/menus/arch-applications.menu >my-menu | |||
Change your menu file to include generated menu. | Change your menu file to include the generated menu. | ||
For example add line: | For example, add this line: | ||
[include] (my-menu) | |||
[include] (my-menu) | |||
==== With update-menus ==== | ==== With update-menus ==== | ||
* Uncomment blackbox in /etc/update-menus.conf | * Uncomment ''blackbox'' in {{ic|/etc/update-menus.conf}}. | ||
* | * Run {{ic|update-menus}} as root. | ||
* | * Change your menu file to include the generated menu. | ||
For example add line: | For example, add this line: | ||
[include] (/var/cache/xdg-menu/blackbox/boxrc) | |||
[include] (/var/cache/xdg-menu/blackbox/boxrc) | |||
== See also == | == See also == |
Latest revision as of 05:15, 12 May 2023
xdg-menu is a tool that generates XDG Desktop Menus for the following window managers:
KDE, GNOME, Xfce and Enlightenment are already XDG compatible.
Installation
Install the archlinux-xdg-menu package.
Menu hierarchy
- Applications
- Accessibility
- Accessories
- Development
- Education
- Games
- Graphics
- Internet
- Multimedia
- Office
- Other
- Science
- System
Configuration
xdg_menu relies on three sets of information to generate menus: a root menu or in other words an XML menu template generally passed on the command line, information cached when it was last run, and a series of configuration files.
- You can find some XML menu templates in
/etc/xdg/menus
. - If altering the code in xdg_menu to change layout, make sure you delete everything in
~/.xdg_menu_cache
or you will spend hours trying to figure out why your changes to the perl script do not take. - You can find individual application configurations in
/usr/share/applications
.
Other configuration file directories can be found under /usr/share
. In most cases you will not need to touch these. However if you want to change how your menu is layed out you can alter the menu template for minor changes. Major changes require tweaking the actual xdg_menu perl script. If you find that applications do not appear or that they are called strange things, then you will need to look at the .desktop file in /usr/share/applications
. Check the desktop entry specification.
Adding desktop entries from other directories
By default, the Xdg-menu will be populated with applications which install their desktop entries to /usr/share/applications
. To add applications to the menu which install their desktop entry to a user folder such as ~/.local/share/applications
, edit the /etc/xdg/menus/arch-applications.menu
file and add an <AppDir>
tag for the relevant directory, see below:
/etc/xdg/menus/arch-applications.menu
<Menu> <Name>Applications</Name> <Directory>Arch-Applications.directory</Directory> <DefaultAppDirs/> <AppDir>/home/username/.local/share/applications</AppDir> <DefaultDirectoryDirs/> <DefaultMergeDirs/> ...
Usage
xdg_menu [--format <format>] [--desktop <desktop>] [--charset <charset>] [--language <language>] [--root-menu <root-menu>] [--die-on-error] [--fullmenu] [--help] format - output format possible formats: twm, WindowMaker, fvwm2, icewm, ion3 blackbox, fluxbox, openbox, xfce4, openbox3, openbox3-pipe, awesome readable default: WindowMaker fullmenu - output a full menu and not only a submenu desktop - desktop name for NotShowIn and OnlyShowIn default: the same as format charset - output charset default: <locale> language - output language default: <locale> root-menu - location of root menu file default: /opt/gnome/etc/xdg/menus/applications.menu die-on-error - abort execution on any error, default: try to continue verbose - print debugging information help - print this text
update-menus updates WM's menus from XDG data and can be configured to do it automaticaly.
This is a script wrapper around xdg_menu that relies on /etc/update-menus.conf
To use it, you need to install the archlinux-xdg-menu package (xdg_menu)
In /etc/update-menus.conf
, you have to select from a list of window managers for which the menu should be generated. Comments with # are allowed.
All generated menus are placed in /var/cache/xdg-menu/
. See wm-specific #Examples section of this page to get more information.
Examples
Awesome
$ xdg_menu --format awesome --root-menu /etc/xdg/menus/arch-applications.menu > ~/.config/awesome/archmenu.lua
Then, edit your rc.lua
as shown below.
- Add a require statment for your new
menu.lua
file. - Add an entry to your
awful.menu
object for your new menu which callsxdg-menu
.
... xdg_menu = require("archmenu") ... ... mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon }, { "Applications", xdgmenu }, { "open terminal", terminal } } }) ...
IceWM
$ xdg_menu --format icewm --fullmenu --root-menu /etc/xdg/menus/arch-applications.menu >> ~/.icewm/programs
- Uncomment icewm in
/etc/update-menus.conf
. - Run
update-menus
as root. - Make a symlink to
/var/cache/xdg-menu/icewm/programs
in~/.icewm/programs
.
FluxBox
$ xdg_menu --format fluxbox --root-menu /etc/xdg/menus/arch-applications.menu > ~/.fluxbox/my-menu
Change your menu file to include the generated menu.
For example, add this line:
[include] (my-menu)
- Uncomment fluxbox in
/etc/update-menus.conf
. - Run
update-menus
as root. - Change your menu file to include generated menu.
For example, add this line:
[include] (/var/cache/xdg-menu/fluxbox/boxrc)
OpenBox
Generate menu with:
$ xdg_menu --format openbox3 --root-menu /etc/xdg/menus/arch-applications.menu > xdg-menu.xml
And manually add it into your menu.xml
. For example, put xdg-menu.xml
into menu.xml
and add:
<menu id="Applications" />
Into root-menu
.
Using xdg_open as a pipe menu gives you the added benefit of having a menu that automatically updates when you install new applications.
Add the following somewhere inside your menu.xml between your root menu tags:
<menu id="applications" label="Applications" execute="xdg_menu --format openbox3-pipe --root-menu /etc/xdg/menus/arch-applications.menu" />
A very basic example:
<?xml version="1.0" encoding="UTF-8"?> <openbox_menu xmlns="http://openbox.org/3.4/menu"> <menu id="root-menu" label="Openbox 3"> <menu id="applications" label="Applications" execute="xdg_menu --format openbox3-pipe --root-menu /etc/xdg/menus/arch-applications.menu" /> <separator /> <item label="Log Out"> <action name="Exit"> <prompt>yes</prompt> </action> </item> </menu> </openbox_menu>
- Uncomment openbox in
/etc/update-menus.conf
. - Run
update-menus
as root. - Change your
menu.xml
file to include generated menu.
For example, add following to root-menu:
<menu id="xdg-menu" label="XDG Menu" execute="cat /var/cache/xdg-menu/openbox/menu.xml"/>
Twm
Use:
$ xdg_menu --format twm --root-menu /etc/xdg/menus/arch-applications.menu >my-twm-menu
And add it into twmrc manually. In the case of twm derivatives with m4 preprocessing such as vtwm or ctwm it can be included by adding:
sinclude(`/PATH/TO/my-twm-menu')
To *twmrc
.
- Uncomment twm in
/etc/update-menus.conf
. - Add in
/etc/X11/twm/system.twmrc
a file applications menu (add it intodefops menu
):
"apps" f.menu "Applications"
- Run
update-menus
as root. - Run
twm -f /var/cache/xdg-menu/twm/twmrc
.
/etc/X11/twm/system.twmrc
.WindowMaker
Use:
$ xdg_menu --format WindowMaker --root-menu /etc/xdg/menus/arch-applications.menu >my-wm-menu
And add:
#include "my-wm-menu"
Into your WindowMaker menu file.
You can also use the WPrefs "Application Menu Definitions", and add the xdg command as a parameter in a "Generated Submenu" object.
- Uncomment WindowMaker in
/etc/update-menus.conf
. - Run
update-menus
as root. - Add:
#include "/var/cache/xdg-menu/WindowMaker/wmrc"
Into your menu file.
Fvwm2
Generate the menu:
$ xdg_menu --format fvwm2 --root-menu /etc/xdg/menus/arch-applications.menu >fvwm2-menu
And add it into the root menu:
read fvwm2-menu AddToMenu MenuFvwmRoot "Root Menu" Title + "&0. XDG Menu" Popup xdg_menu
- Uncomment fvwm2 in
/etc/update-menus.conf
. - Run
update-menus
as root. - Change your
.fvwm2rc
file to include generated menu. For example:
AddToMenu MenuFvwmRoot "Root Menu" Title + "&0. XDG Menu" Popup xdg_menu
read /var/cache/xdg-menu/fvwm2/fvwm2rc
BlackBox
$ xdg_menu --format blackbox --root-menu /etc/xdg/menus/arch-applications.menu >my-menu
Change your menu file to include the generated menu.
For example, add this line:
[include] (my-menu)
- Uncomment blackbox in
/etc/update-menus.conf
. - Run
update-menus
as root. - Change your menu file to include the generated menu.
For example, add this line:
[include] (/var/cache/xdg-menu/blackbox/boxrc)