Advertisement
ezarchproject

CUDM.sh (Console User Display Management)

Jan 21st, 2015
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 6.26 KB | None | 0 0
  1. #!/bin/bash
  2. #-------------------------------------------------------------------------------
  3. # Script Created by Vincent - EZ-Arch Project (ezarchproject@gmail.com)
  4. # Distro Sourceforge - https://sourceforge.net/projects/ezarchlinux/
  5. # Distro Dailymotion -   http://www.dailymotion.com/ezarchproject
  6. #
  7. # I shall be using Dailymotion more for the videos instead of Youtube.
  8. #
  9. #-------------------------------------------------------------------------------
  10. #This program is free software: you can redistribute it and/or modify
  11. #it under the terms of the GNU General Public License as published by
  12. #the Free Software Foundation, either version 3 of the License, or
  13. #(at your option) any later version.
  14. #
  15. #This program is distributed in the hope that it will be useful,
  16. #but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18. #GNU General Public License for more details.
  19. #
  20. #You should have received a copy of the GNU General Public License
  21. #along with this program.  If not, see <http://www.gnu.org/licenses/>.
  22. #-------------------------------------------------------------------------------
  23. # Run this script after your first boot with archlinux (as root)
  24. #--------------------------------------------------------------------------------
  25. # Explaination of the Script:
  26. #
  27. #
  28. # User Menu Program
  29. #
  30. ##########################################################################
  31. PROGDIR=/home/vincent/Projects/EzCUDM/rootfs/usr/INSTALLER/EzCUDM # Testing
  32. #PROGDIR=/usr/INSTALLER/EzCUDM
  33.  
  34.  
  35. # Global Stuff
  36.  
  37. CONFIGFILE=$PROGDIR/etc/ezcudm.conf # Config File
  38.  
  39. if [[ -f $CONFIGFILE ]]; then
  40.   source $CONFIGFILE
  41. else
  42.   echo "Error missing file: ezcudm.conf - Required by program"
  43.   echo "Installer's Directory is $PROGDIR/etc"
  44.   exit 1
  45. fi
  46.  
  47. # Linux name and version is set in the program and not the config file
  48.  
  49.  
  50. VERSIONINFO=$PROGDIR/etc/distver.conf
  51.  
  52. if [[ -f $VERSIONINFO ]]; then
  53.   source $VERSIONINFO
  54. else
  55.   echo "Error missing file: distver.conf - Required by program"
  56.   echo "Installer's Directory is $PROGDIR/etc"
  57.   exit 1
  58. fi
  59.  
  60.  
  61. ### Program for making the UI
  62.  
  63. DIALOG=${DIALOG=dialog}
  64. #DIALOG=${DIALOG=Xdialog}
  65.  
  66. # Temp files
  67.  
  68. tempfile=`tempfile 2> /dev/null` || tempfile=/tmp/tmpfile$$
  69. trap "rm  -f $tempfile" 0 1 2 5 15
  70.  
  71.  
  72. ###############################################################################
  73.  
  74. #           Menus are here
  75. #           It will be menu then choices for that menu
  76.  
  77. ############################################################################
  78.  
  79.  
  80.  
  81. mainmenu()
  82. {
  83. while :
  84. do
  85.  
  86. $DIALOG --backtitle "$DISTNAME $DISTVER " --no-shadow \
  87.         --ok-label 'Select' --cancel-label 'Exit' \
  88.         --title "$FUNCTION" --menu "Select a menu option" 20 78 16 \
  89.         "Install $DISTNAME" "Installs the OS to system" \
  90.         "Console" "Spawns a shell of choice" \
  91.         "XSession" "Runs X Session of choice" \
  92.         "Midnight Commander" "File Manager utility" \
  93.         "View Diskspace" "Shows disk spaces via df" \
  94.         "View System Info" "Shows information about your system" \
  95.         "Reboot" "Reboot System." \
  96.         "Power Off" "Power off the System" 2> $tempfile
  97.        
  98.        
  99.        
  100.         mmretval=$?
  101.        
  102.         choice=`cat $tempfile`
  103.        
  104.     case $mmretval in      
  105.     0)
  106.         echo "Selected $choice "
  107.         mainmenuchoices
  108.     ;;
  109.  
  110.     1)
  111.     if $DIALOG --yesno "Do you wish to exit.\nThis will respawn on tty1\nOn other ttys it will exit to the console" 10 40
  112.     then
  113.         exit 0
  114.     fi
  115.    
  116.     ;;
  117.     255)
  118.    # echo "ESC key pressed"
  119.    
  120.     ;;
  121. esac
  122.  
  123.  
  124. done
  125. }
  126. ##### Main Menu Choices Responses
  127.  
  128. mainmenuchoices()
  129. {
  130.             case $choice in
  131.            
  132.                 "Install $DISTNAME")
  133.                     $SETUP
  134.                            
  135.                 ;;
  136.                
  137.                 "Console")
  138.                     shellmenu
  139.                 ;;
  140.                
  141.                 "XSession")
  142.                     xorgmenu
  143.                 ;;
  144.                
  145.                 "Midnight Commander")
  146.                 mc
  147.                 ;;
  148.                
  149.                 "View Diskspace")
  150.                 $DF -h  > $TMP/statsfile.$$
  151.             $DIALOG --backtitle "$DISTNAME $DISTVER" \
  152.                     --title "View Disk Spaces" \
  153.                     --textbox $TMP/statsfile.$$ 20 100
  154.             rm -f $TMP/statsfile.$$
  155.                 ;;
  156.                
  157.                 "View System Info")
  158.                 #-c 0 on Inxi disables Colors
  159.             #
  160.             $INXI -F -c 0  > $TMP/statsfile.$$
  161.             $DIALOG --backtitle "$DISTNAME $DISTVER" \
  162.                     --title "View System Information" \
  163.                     --textbox $TMP/statsfile.$$ 30 100
  164.             rm -f $TMP/statsfile.$$
  165.                 ;;
  166.                
  167.                 "Reboot")
  168.                 $REBOOT
  169.                 ;;
  170.            
  171.                
  172.                 "Power Off")
  173.                 $POWEROFF
  174.                 ;;
  175.             esac
  176.  
  177.  
  178.    
  179.    
  180. }
  181.  
  182.  
  183. ####### Shell Menu & Choices ---------------------------------------------
  184.  
  185. shellmenu()
  186. {
  187.     while :
  188.     do
  189.     $DIALOG --backtitle "$DISTNAME $DISTVER " --no-shadow \
  190.         --ok-label 'Select' --cancel-label 'Back' \
  191.         --title "Select Shell to use for console" --menu "Select a menu option" 20 78 16 \
  192.         "Bash" "Bash Shell" \
  193.         "ZSH" "ZSH Shell" \
  194.         "MKHS" "MirBSD Korn Shell" \
  195.         "TCSH" "GNU C Shell" 2> $tempfile
  196.        
  197.        
  198.         shmenuretval=$?
  199.        
  200.         shchoice=`cat $tempfile`
  201.        
  202.         case $shmenuretval in      
  203.         0)
  204.             echo "Selected $shchoice "
  205.             shellmenuchoice
  206.             break
  207.         ;;
  208.  
  209.         1)
  210.         echo "Cancalled"
  211.         break
  212.         ;;
  213.         255)
  214.         # echo "ESC key pressed"
  215.    
  216.         ;;
  217. esac
  218.     done
  219. }
  220.  
  221. shellmenuchoice()
  222.  
  223. {
  224.    
  225.     echo
  226.     echo "Now Entering a Shell, type exit to return to main menu"
  227.     echo
  228.     case $shchoice in
  229.    
  230.             "Bash")
  231.                 $BASH
  232.             ;;
  233.             "ZSH")
  234.                 $ZSH
  235.             ;;
  236.             "MKHS")
  237.                 dfspace
  238.                 $MKSH
  239.             ;;
  240.             "TCSH")
  241.                 dfspace
  242.                 $TCSH
  243.             ;;
  244.            
  245.    
  246.     esac
  247.  
  248.  
  249. }
  250.  
  251. ####### Shell Menu & Choices ---------------------------------------------
  252.  
  253. xorgmenu()
  254. {
  255.     while :
  256.     do
  257.     $DIALOG --backtitle "$DISTNAME $DISTVER " --no-shadow \
  258.         --ok-label 'Select' --cancel-label 'Back' \
  259.         --title "Select Xsession to use" --menu "Select a menu option" 20 78 16 \
  260.         "Open Motif" "Open Motif Window Manager" \
  261.         "IceWM" "IceWM - Window Manager" \
  262.         "AWESOME" "Awesome Tiled Window Manager" \
  263.         "TWM" "Tab Window Manager" 2> $tempfile
  264.        
  265.        
  266.         xorgmenuretval=$?
  267.        
  268.         xorgchoice=`cat $tempfile`
  269.        
  270.         case $xorgmenuretval in    
  271.         0)
  272.             echo "Selected $shchoice "
  273.             xorgmenuchoice
  274.         ;;
  275.  
  276.         1)
  277.         echo "Cancalled"
  278.         break
  279.         ;;
  280.         255)
  281.         # echo "ESC key pressed"
  282.    
  283.         ;;
  284. esac
  285.     done
  286. }
  287.  
  288. xorgmenuchoice()
  289.  
  290. {
  291.    
  292.    
  293.     echo
  294.     case $xorgchoice in
  295.    
  296.             "Open Motif")
  297.                 startx $OPENMOTIF
  298.             ;;
  299.             "IceWM")
  300.                 startx $ICEWM
  301.             ;;
  302.             "AWESOME")
  303.                 startx $AWESOME
  304.             ;;
  305.             "TWM")
  306.                 startx $TWM
  307.             ;;
  308.            
  309.    
  310.     esac
  311.  
  312. }
  313.  
  314.  
  315.  
  316. mainmenu
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement