Text and graphics interfaces
Dialog is a tool used to create a dialog box in shell script. You can use dialog to create different information and problem windows to facilitate the script.
Dialog creates a text interface in terminal mode, and a tool compatible with the dialog syntax is called xdialog. xdialog is used to create a graphical interface in X window. Xdialog uses GTK + graphics tools to complete a variety of dialogs, which can be integrated into different desktop themes. Http://xdialog.free.fr/
In addition to xdialog, zenity can also be rewritten from gdialog.
Install: sudo apt-get install dialog xdialog zenity
Xdialog not found...
Use dialog
Currently, the following dialog box functions are supported:
Calendar, checklist, form, fselect, gauge, infobox, inputbox, inputmenu, menu, msgbox (message), password, pause, radiolist, tailbox, tailboxbg, textbox, timebox, and yesno (yes/no)
The syntax of these dialog boxes must have at least three parameters: title or information content, window height, and width.
Common usage:
Display Information: dialog -- msgbox content height and width
Press confirm to leave the status is 0, Press esc to leave the status is 255, you can use $? To check the user's response to the window.
Example
#! /Bin/bash
DIA = '/usr/bin/dialog'
$ DIA -- msgbox "Quiz 1" 10 40
X = $?
If ["$ x"-eq 0]; then
Echo "you press Enter"
Elif ["$ x"-eq 255]; then
Echo "You Press Esc"
Else
Echo "Unknown error"
Fi
Result
Progress bar
#! /Bin/bash
{
For (I = 1; I <= 10; I ++ ))
Do
Let I = 10 * I
Echo $ I
Sleep 1
Done
} | Dialog -- gauge "progress" 5 60 0
Xdialog is compatible with most dialog syntaxes. You only need to change it to Xdialog. But more diverse dialog boxes are supported ..