Linux whiptail tui

概览:

效果一览

实现代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/sh

do_info() {
whiptail --msgbox "display tool info" 20 60 1
}

do_change() {
whiptail --msgbox "Now tools is changing" 20 60 1
}

do_finish() {
whiptail --msgbox "finish configure" 20 60 1
}

while true; do
FUN=$(whiptail --menu "Test Window" 20 80 10 --cancel-button Exit \
"info" "about this tool" \
"change" "configure this tool" \
"finish" "Finish config" \
3>&1 1>&2 2>&3)
if [ $? -ne 0 ]; then
exit 1;
else
"do_$FUN" || whiptail --msgbox "There was an error running do_$FUN" 20 60 1
fi
done