Sawfish manages its menus with a companion program
sawfish-menu. You can use that program even if you aren't running Sawfish as your window manager. The protocol between sawfish and sawfish-menu doesn't seem to be documented anywhere; it's inspired from the menu specification format in Sawfish itself.
echo '(popup-menu (("_toplevel" 0) ("_submenu" ("_foo" 1) () ("_bar" 2))))' |
0 if the user selects “toplevel”, etc. You can specify strings (in double quotes, or even without quotes if they're valid Lisp identifiers) instead of numbers for the entries. If the user aborts (e.g. by pressing Esc) then the output is
Here's a summary of the input syntax of
- Start with
(popup-menu and end with
- For a clickable menu entry, use
("TEXT" OUTPUT) where TEXT is the text of the entry and OUTPUT is what the program prints if this menu entry is selected.
- If there is an underscore in TEXT, the next character is the accelerator for that entry.
- You can put a check mark in front of a menu entry by adding
(check . t), e.g.
("Foo" 42 (check . t)).
- You can put a bullet (radio button) in front of a menu entry by adding
(group . SOMETHING) (check . t). Only one entry within a given group can have the button.
- You can make an entry be greyed out and non-selectable by adding
(insensitive . t).
- For a submenu, use
- For a separator, use
Obviously, don't expect people to have this utility installed. It's typically not packaged separately from Sawfish, but it doesn't actually need anything from Sawfish itself; it's a rep script, rep being the Lisp dialect that Sawfish (and basically nothing else) is written in. On Debian, you need the
rep-gtk package to run
sawfish-menu, plus the script itself.