easybashgui functions
Only these...
message & [ok|alert|notify]_message
question
text
input
menu ( & tagged_menu ) & list
fselect & dselect
wait_seconds & wait_for & terminate_wait_for
progress
adjust
notify (*)
notify_change (*)
( * = only with "yad" installed in your system )
(Note: Since EasyBashGUI v.1.2.4, all windows functions support options "<-w|--width> [integer]", and "<-h|--height> [integer]" for custom window size:
>alert_message -w 400 -h 340 "Error!"
>ok_message --width 300 --height 200 "Hello World! \n ...and thanks for the fish!" )
(1) = "0" exit status is "YES", "1" exit status is "NOT", other exit codes you should make program exit : normally in a script you have just to check exit status to know user choice ;
(2) = "text" function writes text from STDIN to file "${dir_tmp}/${file_tmp}" and (only for yad, kdialog, zenity, and Xdialog) you can also edit it, (since 7.0.2 vers., if you want avoid this use "-F" switch);
(3) = "wait_for" function creates a window with a text, then returns control to main program... after the job, you would close the window throught function called "terminate_wait_for" ;
(4) = take care that if you are in "console mode" or without X, throught cdialog, selection is done by SPACE key, and not by enter key ;
(5) = "menu" function allows only one item selected; on the contrary "list" allows multiple choices and with "+" or "-" you can tell it to display them already selected or not; "tagged_menu" displays "tags" and returns "items" ;
(6) = Since 6.0.0 version, IF 'easybashlib' library is successfully loaded (if not you will have an alert message) clean_temp() is not mandatory anymore at the end of your scripts (to remove temp files), since easybashlib does it automatically (NOTE: this automagic seems sometimes to fail).
(7) = Since 10.0.0 version, "input 1" is no more limited to one argument, so now you can type "input 1 color yellow";
(8) = Three optional arguments: -c (click command for left mouse button on tray icon), -i (the two icons -good and bad- cutted by '#' char), -t (the two tooltips -good and bad- cutted by '#' char), then you have to specify the menu item #1 and its related command, menu item #2 and its related command, and so forth (see example below);
(9) = Two optional arguments: -i (the new icon), -t (the new tooltip), then you have to set the argument ("good" or "bad"), to make notification change to "good" or "bad" condition; (Please, see example #9 below... )
(1) = You would use these variables in this way:
>export supermode="gum" ; source easybashgui
>export supertitle="My great script" ; source easybashgui
>export supericon="error" ; export supermode="kdialog" ; source easybashgui
>export supertitle="My Company Account Manager" ; export supericon="/usr/share/icons/gnome/32x32/apps/system-users.png"; source easybashgui
§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§
Examples:
(Note: if you install my library, then you will type "source easybashgui" before all commands... otherwise you could simply embed it in your project, soon more info about this way! )
1)
question "Do you like Country music ?"
answer="${?}"
if [ ${answer} -eq 0 ]
then
ok_message "You do like it :)"
elif [ ${answer} -eq 1 ]
then
alert_message "You don't like it :("
else
ok_message "See you..."
exit 0
fi
2)
echo -e "What's your name?\n\nYour name's:\n???" | text
echo -e "What's your name?\n\nMy name's:\nVittorio\n\nand I don't want you edit this..." | text -F
3)
wait_for "I'm sleeping 4 seconds... good night..."
sleep 4
terminate_wait_for
4)
fselect
file="$(0< "${dir_tmp}/${file_tmp}" )"
5)
input 1 "Please write your IP address:" "192.168.1.2" && ip_address="$(0< "${dir_tmp}/${file_tmp}" )"
input 1 "(write here IP address)" && ip_address="$(0< "${dir_tmp}/${file_tmp}" )"
input 3 "Username" "root" "IP address" "192.168.0.1" "Destination directory" "/tmp"
IFS=$'\n' ; choices=( $(0< "${dir_tmp}/${file_tmp}" ) ) ; IFS=$' \t\n'
user="${choices[0]}"
ip="${choices[1]}"
dir="${choices[2]}"
6)
adjust "Please, set Volume level" 150 230 400
volume_to_set="$(0< "${dir_tmp}/${file_tmp}" )"
7)
for i in 13 27 31 35 40 53 57 63 70 82 83 96 100
do
echo "${i}"
sleep 2
done | progress "This is a test progress depending on percent in StdIn..."
for char in A B C
do
echo "PROGRESS"
sleep 2
done | progress "This is a test progress depending on steps \n (you need an other argument: 3)..." "3"
# see next example...
8)
women=( Angela Carla Michelle Noemi Urma Marisa Karina Anita Josephine Rachel )
for (( index=0 ; index < ${#women[@]} ; index++ ))
do
today_woman="${women[${index}]}"
kiss "${today_woman}"
#
# Job done !!
# then =>
echo "PROGRESS"
#
done | progress "This is a _LOVE_ progress..." "${#women[@]}"
9)
notify -c "xcalc" -t "Good tooltip:OK#Bad tooltip:BAD" -i "/usr/local/share/pixmaps/nm-signal-100.png#gtk-fullscreen" "What time is it" "xclock" "Look at this" "xeyes"
#
while :
do
menu GOOD BAD
answer=$(0< "${dir_tmp}/${file_tmp}" )
#
if [ "${answer}" = "GOOD" ]
then
notify_message "Changed in \"good\" notification..."
#
notify_change -t "Yeahhh!" "good"
#
elif [ "${answer}" = "BAD" ]
then
notify_message -i "gtk-help" "Changed in \"bad\" notification..."
#
notify_change -i "/usr/share/pixmaps/help.png "bad"
#
else
exit
fi
#
done
I like example #8... ;-D