Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

gamelauncher 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #!/usr/bin/env bash
  2. # AUTHOR: shaggy
  3. # FILE: gamelauncher.sh
  4. # ROLE: TODO (some explanation)
  5. # CREATED: 2015-05-18 22:51:55
  6. # MODIFIED: 2015-05-18 22:51:56
  7. # A menu driven shell script sample template
  8. ## ----------------------------------
  9. # Step #1: Define variables
  10. # ----------------------------------
  11. EDITOR=vim
  12. PASSWD=/etc/passwd
  13. RED='\033[0;41;30m'
  14. STD='\033[0;0;39m'
  15. # ----------------------------------
  16. # Step #2: User defined function
  17. # ----------------------------------
  18. pause(){
  19. read -p "Press [Enter] key to continue..." fackEnterKey
  20. }
  21. one(){
  22. echo "one() called"
  23. pause
  24. }
  25. # do something in two()
  26. two(){
  27. echo "two() called"
  28. pause
  29. }
  30. # function to display menus
  31. show_menus() {
  32. clear
  33. echo "~~~~~~~~~~~~~~~~~~~~~"
  34. echo " M A I N - M E N U"
  35. echo "~~~~~~~~~~~~~~~~~~~~~"
  36. echo "1. Set Terminal"
  37. echo "2. Reset Terminal"
  38. echo "3. Exit"
  39. }
  40. # read input from the keyboard and take a action
  41. # invoke the one() when the user select 1 from the menu option.
  42. # invoke the two() when the user select 2 from the menu option.
  43. # Exit when user the user select 3 form the menu option.
  44. read_options(){
  45. local choice
  46. read -p "Enter choice [ 1 - 3] " choice
  47. case $choice in
  48. 1) one ;;
  49. 2) two ;;
  50. 3) exit 0;;
  51. *) echo -e "${RED}Error...${STD}" && sleep 2
  52. esac
  53. }
  54. # ----------------------------------------------
  55. # Step #3: Trap CTRL+C, CTRL+Z and quit singles
  56. # ----------------------------------------------
  57. trap '' SIGINT SIGQUIT SIGTSTP
  58. # -----------------------------------
  59. # Step #4: Main logic - infinite loop
  60. # ------------------------------------
  61. while true
  62. do
  63. show_menus
  64. read_options
  65. done