3

In a simple way, how to create a submenu of dmenu, manpage doesn't help much also archlinux, gentoo wikipage,

Use case: I'd to pip a list of note files to dmenu and then list all that files under a submenu of dmenu.

Steps:

open dmenu
type: notes
submenu with list of notes (piped list files under a folder)
Tuyen Pham
  • 1,765
  • 1
  • 16
  • 46
  • i have no way to test the validity of this thought .... maybe it is possible to have a second dmenu as one of the entries in the first dmenu – jsotola Nov 01 '18 at 16:57
  • Yes, after you type `notes` in dmenu and press `enter`, the first dmenu is destroyed and then another dmenu is appear to server with `list of notes` piped out. Any thoughts? – Tuyen Pham Nov 01 '18 at 17:19

1 Answers1

3

Here's a proof of concept:

#!/bin/bash
#
# Dmenu picker with sub entries

options=("Note books" Files)
choice=$(printf "%s\n" "${options[@]}" | dmenu)
[ $? = 0 ] || exit

case $choice in
    "Note books")
        cd ~/notebooks
        note=$(ls | dmenu)
        [ $? = 0 ] || exit
        gedit "$note"
        ;;
    Files)
        cd ~
        file=$(ls | dmenu)
        [ $? = 0 ] || exit
        xdg-open "$file"
        ;;
esac

If you make that script executable in your $PATH, then dmenu_run can find it also.

Morphit
  • 221
  • 1
  • 6