File tree Expand file tree Collapse file tree 1 file changed +36
-18
lines changed Expand file tree Collapse file tree 1 file changed +36
-18
lines changed Original file line number Diff line number Diff line change @@ -8,14 +8,6 @@ OUTPUT=/tmp/output.sh.$$
8
8
# trap and delete temp files
9
9
trap " rm $OUTPUT ; rm $INPUT ; exit" SIGHUP SIGINT SIGTERM
10
10
11
- function display_output(){
12
- local h=${1-10} # box height default 10
13
- local w=${2-41} # box width default 41
14
- local t=${3-Output} # box title
15
- dialog --backtitle " Select the command to execute: " --title " ${t} " --clear --msgbox " $( < $OUTPUT ) " ${h} ${w}
16
- #
17
- }
18
-
19
11
declare -a CAPTIONS
20
12
declare -a COMMANDS
21
13
@@ -38,22 +30,48 @@ do OPTIONS="$OPTIONS $i ${CAPTIONS[$i]}"
38
30
done
39
31
40
32
33
+ # Define the dialog exit status codes
34
+ : ${DIALOG_OK=0}
35
+ : ${DIALOG_CANCEL=1}
36
+ : ${DIALOG_HELP=2}
37
+ : ${DIALOG_EXTRA=3}
38
+ : ${DIALOG_ITEM_HELP=4}
39
+ : ${DIALOG_ESC=255}
40
+
41
+
41
42
while true
42
43
do
43
-
44
+ exec 3>&1
44
45
# ## display main menu ###
45
- dialog \
46
- --clear \
47
- --backtitle " di-exec" \
48
- --title " [ SELECT A COMMAND ]" \
49
- --menu " Use UP/DOWN arrow keys, Choose the command" 15 150 4 \
50
- $OPTIONS 2> " ${INPUT} "
51
-
52
- menuitem=$( < " ${INPUT} " )
46
+ menuitem=$( dialog \
47
+ --clear \
48
+ --backtitle " di-exec" \
49
+ --title " [ SELECT A COMMAND ]" \
50
+ --cancel-label " Exit" \
51
+ --menu " Use UP/DOWN arrow keys, Choose the command" \
52
+ 20 150 12 \
53
+ $OPTIONS \
54
+ 2>&1 1>&3 )
55
+
56
+ exit_status=$?
57
+
58
+ exec 3>& -
59
+ case $exit_status in
60
+ $DIALOG_CANCEL )
61
+ clear
62
+ echo " Program terminated."
63
+ exit
64
+ ;;
65
+ $DIALOG_ESC )
66
+ clear
67
+ echo " Program aborted." >&2
68
+ exit 1
69
+ ;;
70
+ esac
53
71
54
72
clear
55
73
echo " Executing! \" ${COMMANDS[$menuitem]} \" " $' \n\n '
56
- sleep 2
74
+ sleep 1
57
75
eval ${COMMANDS[$menuitem]}
58
76
read -p " Press [Enter] key to continue..."
59
77
You can’t perform that action at this time.
0 commit comments