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)
2
  • 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 Commented Nov 1, 2018 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? Commented Nov 1, 2018 at 17:19

1 Answer 1

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.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.