Checkboxes with bash script
Alternatively, you can use my library at https://sites.google.com/site/easybashgui
It detects automatically if dialog or whiptail is installed. (Normally, at least one of two is always present even in bare systems...)
So your scripts becomes:
source easybashgui; menu 1 2 3 ; clean_temp
Why reinventing the wheel? ;P
If you just want the checkboxes in a script, you can use the whiptail(1)
or dialog(1)
tools to create the checkboxes:
$ whiptail --checklist "Please pick one" 10 60 5 one one off two two off\
three three off four four off five five off
┌──────────────────────────────────────────────────────────┐
│ [ ] one one │
│ [*] two two │
│ [ ] three three │
│ [*] four four │
│ [ ] five five │
│ │
│ <Ok> <Cancel> │
│ │
└──────────────────────────────────────────────────────────┘
"two" "four"$
The final "two" "four"
is the selected entries returned from the whiptail(1)
program.
If you're programming this for the fun of it yourself, let me know and I'll just convert this to a comment in the hopes that someone else will find the hint useful in the future.