Recently, i have a new task which is adding a user account on a Linux box with UI login shell. My project leader suggests a few tools for me to study and finally i pick the the one called pdmenu.
pdmenu is based on dialog command in Linux. So before talking about pdmenu, i would like to show you how to use dialog.
you can install dialog to create simple message box in command console. For Ubuntu user, just apt-get dialog.
1. Create a Hello World message box
dialog --title "Hello" --msgbox 'Hello world!' 6 20
- title – Title of the message box
- msgbox – The text in the message box
- 6 20 – The size of the message box
2. Create a Yes/No message box
dialog --title "Message" --yesno "Are you OK?" 6 25
The box return 0 if yes is chosen and 1 if no.
3. Create a simple menu
dialog --menu "Menu" 10 30 3 1 red 2 green 3 blue 2>temp
Similar to yes/no box, it return 0 if OK and 1 if Cancel. And the selection (1, 2, 3) will be printed in stdout which is direct to a file named as “temp”.
4. Example
The following is a shell script example which help u to list file in /home, /root or /tmp directory.
#!/bin/sh
dialog --menu "List file of a directory" 10 30 3 1 /home 2 /root 3 /tmp 2>temp
# OK is pressed
if [ "$?" = "0" ]
then
_return=$(cat temp)
# /home is selected
if [ "$_return" = "1" ]
then
dialog --title "List file of directory /home" --msgbox "$(ls /home -l)" 100 100
fi
# /root is selected
if [ "$_return" = "2" ]
then
dialog --title "List file of directory /root" --msgbox "$(ls /root -l)" 100 100
fi
# /tmp is selected
if [ "$_return" = "3" ]
then
dialog --title "List file of directory /tmp" --msgbox "$(ls /tmp -l)" 100 100
fi
# Cancel is pressed
else
echo "Cancel is pressed"
fi
# remove the temp file
rm -f temp
There are other examples which can be found at Dialog: An Introductory Tutorial
Done and I will talk about pdmenu later =).

Nice one , But i was searching the implementation using API’s or system calls in Linux 🙂
LikeLike
Thanks. i have no idea how to implement this with lower level linux call. I think that maybe interesting so let me know if you have any findings.
by the way, i got another post about creating menu using pdmenu. See if you are interested. but the pdmenu is built on top of dialog which is not what you want. =P
pdmenu – Create a Simple Menu for Inexperienced Linux Users
LikeLiked by 1 person
Hi there , i have a dunnos
Well its need it
Read Values from ???
Okey i just trying to understand
well i wanna make a Dialog GUI Selector , and when i choise some option , this in the process show a gauge / progress bar .
I put here the script i try to do ->
#!/bin/bash DIALOG=${DIALOG=dialog} Title="Wine Manual Installer" Question="Please Choise a Version : " Versions=( "1.6.2" "1.7.0" "1.7.1" "1.7.2" "1.7.3" "1.7.4" "1.7.5" "1.7.6" "1.7.7" "1.7.8" "1.7.9" "1.7.10" "1.7.11" "1.7.12" "1.7.13" "1.7.14" "1.7.15" "1.7.16" "1.7.17" "1.7.18" "Salir" ) Versions=( ${Versions[@]/#/"FALSE "} ) while true; do Opcion="$( $DIALOG --clear --title "$Title" \ --menu "Wine:" 20 51 4 \ "$Versions" "$Versions" \ ) " if [ "$Opcion" = "1.6.2" ]; then dialog --msgbox "You has been choise $Option, Option 01" 0 0 elif [ "$Opcion" = "1.7.0" ]; then dialog --msgbox "You has been choise $Option, Option 02" 0 0 elif [ "$Opcion" = "1.7.1" ]; then dialog --msgbox "You has been choise $Option, Option 03" 0 0 elif [ "$Opcion" = "1.7.2" ]; then dialog --msgbox "You has been choise $Option, Option 04" 0 0 elif [ "$Opcion" = "1.7.3" ]; then dialog --msgbox "You has been choise $Option, Option 05" 0 0 elif [ "$Opcion" = "1.7.4" ]; then dialog --msgbox "You has been choise $Option, Option 06" 0 0 elif [ "$Opcion" = "1.7.5" ]; then dialog --msgbox "You has been choise $Option, Option 07" 0 0 elif [ "$Opcion" = "1.7.6" ]; then dialog --msgbox "You has been choise $Option, Option 08" 0 0 elif [ "$Opcion" = "1.7.7" ]; then dialog --msgbox "You has been choise $Option, Option 09" 0 0 elif [ "$Opcion" = "1.7.8" ]; then dialog --msgbox "You has been choise $Option, Option 10" 0 0 elif [ "$Opcion" = "1.7.9" ]; then dialog --msgbox "You has been choise $Option, Option 11" 0 0 elif [ "$Opcion" = "1.7.10" ]; then dialog --msgbox "You has been choise $Option, Option 12" 0 0 elif [ "$Opcion" = "1.7.11" ]; then dialog --msgbox "You has been choise $Option, Option 13" 0 0 elif [ "$Opcion" = "1.7.12" ]; then dialog --msgbox "You has been choise $Option, Option 14" 0 0 elif [ "$Opcion" = "1.7.13" ]; then dialog --msgbox "You has been choise $Option, Option 15" 0 0 elif [ "$Opcion" = "1.7.14" ]; then dialog --msgbox "You has been choise $Option, Option 16" 0 0 elif [ "$Opcion" = "1.7.15" ]; then dialog --msgbox "You has been choise $Option, Option 17" 0 0 elif [ "$Opcion" = "1.7.16" ]; then dialog --msgbox "You has been choise $Option, Option 18" 0 0 elif [ "$Opcion" = "1.7.17" ]; then dialog --msgbox "You has been choise $Option, Option 19" 0 0 elif [ "$Opcion" = "1.7.18" ]; then dialog --msgbox "You has been choise $Option, Option 20" 0 0 elif [ "$Opcion" = "Salir" ]; then exit 1 else dialog --msgbox "You has been choise $Option, Invalid Option" fi doneLikeLike
The dialog box will have 2 buttons. If the user select OK, 0 is returned.
LikeLike