home *** CD-ROM | disk | FTP | other *** search
/ PCNET 2006 September - Disc 1 / PCNET_CD_2006_09.iso / linux / puppy-barebones-2.01r2.iso / pup_201.sfs / usr / sbin / video-wizard < prev    next >
Encoding:
Text File  |  2006-05-28  |  5.5 KB  |  148 lines

  1. #!/bin/sh
  2. #BK video-wizard (c) 2003,2004,2005,2006 www.goosee.com/puppy
  3.  
  4. CFREQ1="" #custom frequency, with leading x.
  5. CFREQ0="" #ditto, no x.
  6.  
  7. CURRENTX="`readlink /usr/X11R6/bin/X`"
  8. if [ ! "$CURRENTX" = "Xvesa" ];then
  9.  xmessage -bg "#ff8080" -center -name "xutilities" -title "Xvesa Video Wizard" "The Xvesa Kdrive X server is the default for Puppy, however
  10. is not currently running. The current X server is: $CURRENTX.
  11.  
  12. If Xfbdev, the framebuffer Kdrive X server, or Xorg, the full server,
  13. is running, select the Xfbdev/Xorg Video Wizard from the menu -- they
  14. have the option of switching back to the default Xvesa server.
  15.  
  16. Click OK button to exit..."
  17.  exit
  18. fi
  19.  
  20. Xvesa -listmodes > /tmp/Xmodes.txt 2>&1
  21.  
  22. BLURB0="Welcome to my real-time Video Wizard!"
  23. echo "Press a button to test a video mode." > /tmp/videowizard.txt
  24. echo "IMPORTANT: if a mode does not work, press CTRL-ALT-BACKSPACE" >> /tmp/videowizard.txt
  25. echo "(hold down CTRL and ALT keys and tap BACKSPACE key)." >> /tmp/videowizard.txt
  26. echo "Please remember this key combination. It is the standard Linux" >> /tmp/videowizard.txt
  27. echo "technique for emergency shutdown of the X graphics server." >> /tmp/videowizard.txt
  28. echo "NOTE: x16 is 16-bit color which is 65,536 colors (HighColor)," >> /tmp/videowizard.txt
  29. echo "      x24 is 24-bit color which is 16 million colors (TrueColor)." >> /tmp/videowizard.txt
  30. echo "WARNING: these modes are supported by your video card, but do" >> /tmp/videowizard.txt
  31. echo "not choose a mode that exceeds your monitor capability." >> /tmp/videowizard.txt
  32. echo " "  >> /tmp/videowizard.txt
  33. echo "MORE     offers more video mode choices."  >> /tmp/videowizard.txt
  34. echo "XOPTIONS enables you to specify extra X server startup options." >> /tmp/videowizard.txt
  35. echo " " >> /tmp/videowizard.txt
  36. echo -ne "IF YOU WANT TO USE THE CURRENT MODE, PRESS \"OK\"" >> /tmp/videowizard.txt
  37.  
  38. BUTTONS="640x480x16:10,MORE:16,OK:17"
  39. cat /tmp/Xmodes.txt | grep "0x0118"
  40. if [ $? -eq 0 ];then #=0 if found.
  41. BUTTONS="640x480x16:10,640x480x24:11,800x600x16:12,800x600x24:13,1024x768x16:14,1024x768x24:15,MORE:16,XOPTIONS:18,OK:17"
  42. else
  43.  cat /tmp/Xmodes.txt | grep "0x0117"
  44.  if [ $? -eq 0 ];then #=0 if found.
  45. BUTTONS="640x480x16:10,640x480x24:11,800x600x16:12,800x600x24:13,1024x768x16:14,MORE:16,XOPTIONS:18,OK:17"
  46.  else
  47.   cat /tmp/Xmodes.txt | grep "0x0115"
  48.   if [ $? -eq 0 ];then #=0 if found.
  49. BUTTONS="640x480x16:10,640x480x24:11,800x600x16:12,800x600x24:13,MORE:16,XOPTIONS:18,OK:17"
  50.   else
  51.    cat /tmp/Xmodes.txt | grep "0x0114"
  52.    if [ $? -eq 0 ];then #=0 if found.
  53. BUTTONS="640x480x16:10,640x480x24:11,800x600x16:12,MORE:16,XOPTIONS:18,OK:17"
  54.    else
  55.     cat /tmp/Xmodes.txt | grep "0x0112"
  56.     if [ $? -eq 0 ];then #=0 if found.
  57. BUTTONS="640x480x16:10,640x480x24:11,MORE:16,XOPTIONS:18,OK:17"
  58.     fi
  59.    fi
  60.   fi
  61.  fi
  62. fi
  63.  
  64. #/tmp/videomode only exists when testing a mode...
  65. rm -f /tmp/videomodex #v2.0.0 see /usr/sbin/fitimage2root
  66. if [ -e /tmp/videomode ];then
  67.  CMODE="`cat /tmp/videomode`"
  68.  echo -n "$CMODE" > /tmp/videomodex #v2.0.0
  69.  #in case new mode no good, ctrl-alt-backspace will come up in safe mode...
  70.  echo -n "0x0111 640x480x16" > /tmp/videomode
  71. else
  72.  CMODE="`cat /etc/videomode`"
  73. fi
  74.  
  75. BLURB1="`cat /tmp/videowizard.txt`"
  76.  
  77. while :; do #big loop
  78. STAYX=0
  79.  
  80. xmessage -bg "#ffe0e0" -center -name "xutilities" -title "Puppy Video Wizard. Current mode: $CMODE" -buttons "$BUTTONS" -file -<<MSG1
  81. $BLURB0
  82. $BLURB1
  83. MSG1
  84.  
  85. case ${?} in
  86.    10)# 640x480x16
  87.      echo -n "0x0111 640x480x16$CFREQ1" > /tmp/videomode
  88.      ;;
  89.    11)# 640x480x24     
  90.      echo -n "0x0112 640x480x24$CFREQ1" > /tmp/videomode
  91.      ;;
  92.    12)# 800x600x16     
  93.      echo -n "0x0114 800x600x16$CFREQ1" > /tmp/videomode
  94.      ;;
  95.    13)# 800x600x24     
  96.      echo -n "0x0115 800x600x24$CFREQ1" > /tmp/videomode
  97.      ;;
  98.    14)# 1024x768x16     
  99.      echo -n "0x0117 1024x768x16$CFREQ1" > /tmp/videomode
  100.      ;;
  101.    15)# 1024x768x24
  102.      echo -n "0x0118 1024x768x24$CFREQ1" > /tmp/videomode
  103.      ;;
  104.    16)# MORE complete list of modes...
  105.      exec rxvt -geometry 70x28 -e video-wizard-more
  106.      ;;
  107.    18)# extra options when start X...
  108.      OPTCURRENT="`cat /etc/xextraoptions`"
  109.      OPTNEW="`Xdialog --title "Extra X startup options" --left --stdout --inputbox "-shadow  may give smoother scrolling\n-2button  emulate middle button by pressing both together\n(changes will take effect after X is restarted)" 0 0 "$OPTCURRENT"`"
  110.      if [ $? -eq 0 ];then
  111.       echo -n "$OPTNEW" > /etc/xextraoptions
  112.      fi
  113.      STAYX=1 #flag to stay in X.
  114.      ;;
  115.    17)# = OK
  116.      echo -n "$CMODE" > /etc/videomode
  117.      rm -f /tmp/videomodex #v2.0.0 see /usr/sbin/fitimage2root
  118.      rm -f /tmp/videomode
  119.      rm -f /tmp/videowizard.txt
  120.      rm -f /tmp/Xflag #prevent endless restarts. see xwin*.
  121.      break;;
  122.    0)# i want to handle window close-box...
  123.      break;;
  124.    1)# i want to handle window close-box...
  125.      break;;
  126. esac
  127. if [ $STAYX -eq 0 ];then
  128.  rm -f /tmp/Xflag #prevent endless restarts. see xwin*.
  129.  exec killall X #restart X in new test mode.
  130. fi
  131. done
  132.  
  133. #on very 1st boot, PUPMODE=5, put up a welcome box...
  134. #(for Xorg, see /usr/sbin/delayedrun, called from /root/.xinitrc)
  135. PUPMODE=2
  136. [ -f /etc/rc.d/PUPMODE ] && PUPMODE=`cat /etc/rc.d/PUPMODE`
  137. if [ $PUPMODE -eq 5 ];then
  138.   #rc.modules should have detected sound, loaded module, written to /etc/modprobe.conf.
  139.   #rc.local0 executes rc.alsa to start sound. now bark...
  140.   if [ ! "`grep 'alias snd\-card\-0' /etc/modprobe.conf`" = "" ];then
  141.    aplay /usr/share/audio/2barks.au &
  142.   fi
  143.  dillo --rcfile /etc/welcomedillorc file:///usr/share/doc/welcome1stboot.htm
  144.  killall aplay 2> /dev/null
  145. fi
  146.  
  147. ###end###
  148.