video-wizard 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. #!/bin/sh
  2. #BK video-wizard (c) Copyright 2007 Barry Kauler
  3. #2007 Lesser GPL licence v2 (see: /usr/share/doc/legal)
  4. #written for Puppy v3.00
  5. #bugfix v3.02
  6. #v404 flag to rebuild drive icons (see /sbin/clean_desk_icons).
  7. #w019 apr2009: updated for woof.
  8. #101020 no longer have /etc/modprobe.conf.
  9. #120202 rodin.s: internationalized.
  10. #120213 /var/local/pup_event_icon_change_flag path changed from /tmp (see /sbin/clean_desk_icons)
  11. export TEXTDOMAIN=video-wizard
  12. export TEXTDOMAINDIR=/usr/share/locale
  13. export OUTPUT_CHARSET=UTF-8
  14. eval_gettext () {
  15. local myMESSAGE=$(gettext "$1")
  16. eval echo \"$myMESSAGE\"
  17. }
  18. export LANGORG=$LANG
  19. . /etc/rc.d/PUPSTATE
  20. CURRENTX="`readlink /usr/bin/X`"
  21. if [ "$CURRENTX" != "Xvesa" ];then
  22. Xdialog --title "$(gettext 'Xvesa Video Wizard')" --msgbox "$(gettext 'The Xvesa X server is not currently running.
  23. Select the Xorg Video Wizard from the menu
  24. -- it has the option of switching over to the
  25. Xvesa server. Click OK button to exit...')" 0 0
  26. exit
  27. fi
  28. ALLMODES="`Xvesa -listmodes 2>&1 | grep '^0x' | tr ':' ' ' | tr -s ' ' | cut -f 1,2 -d ' ' | sort -g -k 2 | tr ' ' '|' | tr '\n' ' '`"
  29. #v3.02 verify correct mode-number for 640x480x16... (0x0111)
  30. MODEBASENUM="`echo "$ALLMODES" | tr ' ' '\n' | grep '640x480x16' | cut -f 1 -d '|'`"
  31. if [ -e /tmp/videomode ];then
  32. CURRENTMODE="`cat /tmp/videomode`"
  33. #in case new mode no good, ctrl-alt-backspace will come up in safe mode...
  34. [ "$MODEBASENUM" ] && echo -n "$MODEBASENUM 640x480x16" > /tmp/videomode #v3.02
  35. else
  36. CURRENTMODE="`cat /etc/videomode`"
  37. fi
  38. echo "$CURRENTMODE" > /tmp/xvesacurrentmode #v3.02
  39. CURRENTNUMBER="`echo -n "$CURRENTMODE" | cut -f 1 -d ' '`"
  40. CURRENTVALS="`echo -n "$CURRENTMODE" | cut -f 2 -d ' '`"
  41. [ -f /etc/xextraoptions ] && CURRENTXOPTIONS="`cat /etc/xextraoptions`"
  42. RADIOSECTION=""
  43. for ONEMODE in $ALLMODES
  44. do
  45. MODENUMBER="`echo -n "$ONEMODE" | cut -f 1 -d '|'`"
  46. MODEVALS="`echo -n "$ONEMODE" | cut -f 2 -d '|'`"
  47. XVAL=`echo -n "$MODEVALS" | cut -f 1 -d 'x'`
  48. YVAL=`echo -n "$MODEVALS" | cut -f 2 -d 'x'`
  49. COLDEPTH=`echo -n "$MODEVALS" | cut -f 3 -d 'x'`
  50. [ $XVAL -lt 640 ] && continue
  51. [ $YVAL -lt 480 ] && continue
  52. [ $COLDEPTH -lt 16 ] && continue
  53. RADIOSTATE="false"
  54. [ "$CURRENTNUMBER" = "$MODENUMBER" ] && RADIOSTATE="true"
  55. RADIOSECTION="${RADIOSECTION}
  56. <radiobutton active=\"${RADIOSTATE}\">
  57. <label>${MODEVALS}</label>
  58. <variable>RADIO_${ONEMODE}</variable>
  59. </radiobutton>
  60. "
  61. done
  62. # icon-name=\"gtk-preferences\"
  63. export MAIN_DIALOG="
  64. <window title=\"$(gettext 'Xvesa Video Wizard')\">
  65. <hbox>
  66. <vbox>
  67. <frame $(gettext 'Video modes')>
  68. ${RADIOSECTION}
  69. </frame>
  70. </vbox>
  71. <vbox>
  72. <text>
  73. <label>\" \"</label>
  74. </text>
  75. <text>
  76. <label>$(gettext 'Welcome to the Xvesa Video Wizard!')</label>
  77. </text>
  78. <text>
  79. <label>`eval_gettext \"The current video mode is \\\${CURRENTVALS}. If you want something else, make a choice on the left then click the 'CHANGE' button. If you are happy with the current screen resolution, click the 'OKAY' button.\"`</label>
  80. </text>
  81. <text>
  82. <label>$(gettext 'NOTE: x16 is 16-bit color which is 65,536 colors (HighColor), x24 is 24-bit color which is 16 million colors (TrueColor).')</label>
  83. </text>
  84. <text>
  85. <label>$(gettext 'IMPORTANT: if a mode does not work, press CTRL-ALT-BACKSPACE (hold down CTRL and ALT keys and tap BACKSPACE key). Please remember this key combination. It is the standard Linux technique for emergency shutdown of the X graphics server.')</label>
  86. </text>
  87. <text>
  88. <label>\" \"</label>
  89. </text>
  90. <hbox>
  91. <vbox>
  92. <text>
  93. <label>$(gettext 'For the experts, X server startup options:')</label>
  94. </text>
  95. <entry>
  96. <default>\"${CURRENTXOPTIONS}\"</default>
  97. <variable>ENTRY</variable>
  98. </entry>
  99. </vbox>
  100. <text>
  101. <label>\" \"</label>
  102. </text>
  103. <button>
  104. <label>$(gettext 'CHANGE')</label>
  105. <action type=\"exit\">TESTBUTTON</action>
  106. </button>
  107. <button>
  108. <label>$(gettext 'OKAY')</label>
  109. <action type=\"exit\">OKAYBUTTON</action>
  110. </button>
  111. </hbox>
  112. </vbox>
  113. </hbox>
  114. </window>
  115. "
  116. RETVALS="`gtkdialog3 --program=MAIN_DIALOG`"
  117. echo "$RETVALS"
  118. [ "`echo "$RETVALS" | grep '^EXIT='`" = "" ] && exit #invalid stuff.
  119. [ "`echo "$RETVALS" | grep 'abort'`" != "" ] && exit #invalid stuff.
  120. CHOSENMODE="`echo "$RETVALS" | grep 'RADIO' | grep '"true"' | cut -f 2 -d '_' | cut -f 1 -d '=' | tr '|' ' '`"
  121. CHOSENBUTTON="`echo "$RETVALS" | grep '^EXIT' | cut -f 2 -d '"'`" #'geany
  122. CHOSENXOPTIONS="`echo "$RETVALS" | grep '^ENTRY' | cut -f 2 -d '"'`" #'geany
  123. echo "CHOSENMODE=$CHOSENMODE CHOSENBUTON=$CHOSENBUTTON"
  124. echo -n "$CHOSENMODE" > /tmp/videomode
  125. echo -n "$CHOSENXOPTIONS" > /etc/xextraoptions
  126. if [ "$CHOSENBUTTON" = "TESTBUTTON" ];then
  127. echo 'ICONWIPE' > /var/local/pup_event_icon_change_flag #v404 see /sbin/clean_desk_icons (called from .xinitrc). 120213 path changed from /tmp (see /sbin/clean_desk_icons)
  128. rm -f /tmp/Xflag #prevent endless restarts. see /usr/bin/xwin.
  129. exec killall X #restart X in new test mode.
  130. fi
  131. if [ "$CHOSENBUTTON" = "OKAYBUTTON" ];then
  132. echo -n "$CHOSENMODE" > /etc/videomode
  133. rm -f /tmp/videomode
  134. rm -f /tmp/Xflag #prevent endless restarts. see xwin*.
  135. fi
  136. if [ $PUPMODE -eq 5 ];then
  137. if [ ! "`grep 'alias snd\-card\-0' /etc/modprobe.d/alsa.conf`" = "" ];then #101020
  138. wavplay /usr/share/audio/2barks.wav &
  139. sleep 3
  140. killall wavplay 2> /dev/null
  141. fi
  142. fi
  143. ###END###