Dialog widgets
From wikinotes
return values
Dialog saves it's result to stderr by default. You can change this using the
--stdout
parameter.VAR=$(dialog --menu 'Choose' 10 10 10 \ 0 apples \ 1 oranges \ 2 kiwis)See stack overflow for details of saving dialog results to a variable.
This is ackward. Bash does not support return codes other than 0 or 1. Dialog, by default outputs it's result on stderr (so that it can be redirected into a file then read). To skip the ackward in between step, you can do this:
## __NOTE__: the backslashes are mandatory here result=$( \ dialog --title "Create Directory" \ --inputbox "Enter the directory name:" 8 40 \ 3>&1 1>&2 2>&3 3>&- \ ) echo $result
components
MessageBox
dialog --title 'Message' --msgbox 'Hello, world!' 5 20Yes/No Prompt
dialog --title "Message" --yesno "Are you having\ fun?" 6 25Input Box
# dialog --inputbox text width height dialog --inputbox "Enter your name:" 8 40 2>answerMenu
## dialog --menu <text> <height> <width> dialog --menu "Choose one:" \ 10 30 3 `#height width menu-height` \ 0 red \ 1 green\ 2 blueHere's a real example
colourschemes=(soda hybrid diokai) choices="" for i in ${!colourschemes[@]} ; do choices+=" $i ${colourschemes[$i]}" done result=$(eval "$dialog --menu Choose 10 10 3 $choices --stdout")Gauge (progressbar)
# reads/displays percentage on STDIN until EOF for (( i=0; $i<100; i++ )); do echo "$i" sleep 0.2 done | dialog --gauge foo 10 100Calendar
dialog --calendar \ "title" `# title` \ 1 80 `# width/height` \ 20 10 2020 `# (opt) day/month/year`