easybashgui man page

EasyBashGUI — a Bash functions library to create simple interfaces, using Zenity, GTKDialog, KDialog, XDialog, Dialog, Whiptail, etc, depending on the desktop environment.


source easybashgui


EasyBashGUI helps you to create an interface for your Bash script. The programmer doesn't have to check if the user is using GNOME or KDE, or even if the X.org server is running: EasyBashGUI will do the hard work and choose the type of interface which better integrates with the desktop environment.


message, ok_message, alert_message [text]
Show a simple message dialog to the user.
question [text]
Show a question dialog. The user can answer either "yes" or "no".
The answer is stored in the ${?} variable (0 is "yes", 1 is "no").
Receives text from stdin and displays it in realtime. The text box will be editable by the user (unless you are using "dialog" as front-end).
The edited text is stored in this temporary file: ${dir_tmp}/${file_tmp} (look at the examples).
input [number] ...
Displays a text entry. The number sets the number of entries that should be displayed. If the number is 1, then it must be followed by some text, that will be used as a placeholder in the entry. If the number is 2 or 3, then it must be followed twice or three times by a label and a placeholder. The output is stored in this temporary file: ${dir_tmp}/${file_tmp} (look at the examples).
menu [items]
Shows an exclusive choice list. Use one argument per item. The choice is stored in this temporary file: ${dir_tmp}/${file_tmp} (look at the examples).
list [items]
Shows a multiple choice list. Use one argument per item. You can put a "+" or a "-" at the beginning of the argument to display the item already selected. The choice is stored in this temporary file, one choice per line: ${dir_tmp}/${file_tmp} (look at the examples).
fselect, dselect <dir>
Shows a file/directory selection dialog. If "dir" is provided, the selector will point to that directory by default; otherwise it will point to the current directory. The choice is stored in this temporary file: ${dir_tmp}/${file_tmp} (look at the examples).
wait_for [text]
Shows a waiting dialog or a notification while some other code is running. It runs on the background, so other programs of functions might be executed while wait_for is running. It can be stopped using terminate_wait_for.
Closes the "wait_for" dialog.
wait_seconds [number]
Shows a waiting dialog for number seconds.
progress [text] <n_items>
Shows a progress bar. The progress value is taken from stdin. If n_items is provided, then the progress bar percentage increases only when the program receives PROGRESS from stdin. The percentage will be 100% when the number of PROGRESS received will be equal to n_items (look at the examples).
adjust [text] [min] [default] [max]
Shows a scale (in percent) with the values taken from command line: "max" is the maximum value, "min" is the minimum value and "default" is the default value. The value is stored in this temporary file: ${dir_tmp}/${file_tmp} (look at the examples).
Removes temporary files; it should be run at the end of the script (deprecated since 6.0.0, because "easybashlib" does it automatically).


Forces EasyBashGUI to use a custom program to render the dialogs. Possible values are "yad", "gtkdialog", "kdialog", "zenity", "Xdialog", "dialog", "none" and "auto" (default). When set to "auto", it will choose the program depending on the running desktop environment and on the availability of these programs.


Note that ${dir_tmp}/${file_tmp} is not a simple variable, but a temporary file. Functions that need to store more than one choice (like list and input ) put one choice per line.
You should use cat or similars to get or display the content of the file.


message "This is a sample message"
ok_message "This is a success message"
alert_message "This is an alert message"
question "Do you like open-source software?"
if [ ${answer} -eq 0 ]
ok_message "You do like it :)"
elif [ ${answer} -eq 1 ]
alert_message "You don't like it :("
ok_message "Why didn't you answer?\nSee you..."
exit 0
echo -e "This is a sample text\nwith more than one line.\nYou can write here whatever you want." | text
edited_text="$(0< "${dir_tmp}/${file_tmp}" )"
input (1)
input 1 "Write here an IP address"
ip_address="$(0< "${dir_tmp}/${file_tmp}" )"
input (2)
input 3 "Username" "root" "IP address" "" "Destination directory" "/tmp"
choices=( $(0< "${dir_tmp}/${file_tmp}" ) )
menu "Item 1" "Item 2" "Item3"
choice="$(0< "${dir_tmp}/${file_tmp}" )"
list "+Selected item" "-Unselected item" "+Selected item 2"
choices="$(0< "$dir_tmp/$file_tmp" )"
message "Choices:\n${choices}"
fselect, dselect
fselect ~/Desktop
file="$(0< "${dir_tmp}/${file_tmp}" )"
dselect ~/Documents
directory="$(0< "${dir_tmp}/${file_tmp}" )"
wait_for, terminate_wait_for
wait_for "Downloading file, please wait..."
wget http://www.myfile.com/big_file.tar.gz
message "Download complete."
echo "Waiting for 10 seconds..."
wait_seconds 10
progress (1)
for i in 13 27 31 35 40 53 57 63 70 82 83 96 100
echo "${i}"
sleep 1
done | progress "This is a test progress that shows the percentage received from stdin."
progress (2)
for char in A B C D E F
sleep 2
done | progress "This test progress calculates the percentage depending on the number of items received from stdin and the total number passed as an argument." "6"
adjust "Please set the volume" 30 75 140
volume_to_set="$(0< "${dir_tmp}/${file_tmp}" )"


Written by Vittorio Cagnetta <vaisarger@gmail.com>.
This manpage has been written by Davide Depau <david.dep.1996@gmail.com>.

Reporting Bugs

If you notice misbehaviors or bugs, please report them to <vaisarger@gmail.com>.

See Also

You can find the list of the functions and some examples by visiting EasyBashGUI website <http://sites.google.com/site/easybashgu…>.


Explore man page connections for easybashgui(1).