2

I'm looking for something like Zenity or Yad, except I want something that behaves like a menu, namely: it opens right next to the cursor; it takes one click to select things; it's possible to have multiple levels.

The closest thing I've found is actually Autokey's folders, but Autokey needs to always be running (even if I call autokey-run), which I'd prefer to avoid.

The key requirement is that I be able to single click on something that appears near my cursor.

Any ideas?

3
  • Can't say about context menus, but dmenu and xbindkeys may be of use. – Andrew Miloradovsky Mar 18 '16 at 22:02
  • I'm aware of both. I'm not worried about how to actually bind the keys, and unfortunately, dmenu does not solve the problem; I need it to be accessible by mouse. See the edit. – Alex R Mar 19 '16 at 1:54
  • 1
    Well, then first that comes to mind is openbox, blackbox, fluxbox, windowmaker etc., can't name a single standalone program. – Andrew Miloradovsky Mar 19 '16 at 2:21
2

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))))' |
/usr/lib/sawfish/1.5.3/x86_64-pc-linux-gnu/sawfish-menu

sawfish-menu prints 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 sawfish-menu.

  • 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 ("TEXT" ENTRY…).
  • 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.

1
  • Thanks. This answers the question, so I accepted it; what I'm probably going to end up doing, though, is writing a python script for the specific menu I want. Looking at the source for sawfish-menu was illuminating. – Alex R Mar 20 '16 at 18:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.