0

I am quite new to bash and am trying to figure out how I could print the following menu in a dialog in bash.

#!/bin/bash
while true
do
echo "Welcome to my menu!"
echo "Press 1 to see users"
echo "Press 2 for Calendar"
echo "Press 3 to exit"
echo -e "\n"
echo -e "Enter your selection \c"
read answer
case "$answer" in
1) who
   uptime ;;
2) cal ;;
q) exit ;;
esac
done

I want the user to be able to click on the options instead of pressing a number like in this code.

  • It is difficult to implement mouse-clicking in a shell script because you don't know if your program is run in a graphical terminal window or in a text console. See https://stackoverflow.com/q/8361263/10622916 or https://stackoverflow.com/q/29729770/10622916 for some hints – Bodo Feb 16 '21 at 19:26

1 Answers1

0

While this does not allow clicking on the options your users may prefer a UI built with a program like whiptail or dialog. If you want a mouse based interface you will need to leave the terminal.

Joe
  • 399
  • 2
  • 7