mousecheck 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. #!/bin/sh
  2. #Barry Kauler Oct. 2011. GPL3 (/usr/share/doc/legal)
  3. #called from delayedrun.
  4. #111020 convert from Xdialog to pupdialog, internationalised.
  5. #111021 lutz-ulrich: fix missing translation.
  6. #111026 add 'nowait' param, when call from 'quicksetup'.
  7. [ ! -f /etc/X11/xorg.conf ] && exit
  8. export TEXTDOMAIN=mousecheck
  9. export OUTPUT_CHARSET=UTF-8
  10. PARAM1=""
  11. [ $1 ] && PARAM1="$1"
  12. TABCHAR="`echo -n -e '\t'`"
  13. B_ok=$(gettext 'OK')
  14. B_cancel=$(gettext 'Cancel')
  15. choosemousefunc() { #based on code in /etc/rc.d/functions4puppy4
  16. ALERTMSG1=$(gettext 'Your mouse pointer has not moved, so perhaps it is not working? This dialog window may be operated by the keyboard. \ZbUP/DOWN\ZB arrows then \ZbENTER\ZB key to choose mouse-type, then \ZbTAB\ZB key to select the \ZbOK\ZB button, then ENTER -- X will immediately restart. If your mouse is working, click the \ZbCancel\ZB button.')
  17. ALERTMSG2=$(gettext "NOTICE: If you want, CTRL-ALT-BACKSPACE will terminate X and you can type 'xorgwizard' to run the full Xorg Wizard, to resolve any other problems (such as screen resolution) as well as fix the mouse.")
  18. MOUSEINTRO=$(gettext "Only very old PCs may have a serial mouse. These are recognised by the fairly large rectangular plug, technically known as a DB9 or the even larger DB25 (where the 9 or 25 refers to the number of pins in the plug).")
  19. DETECTEDMOUSEDEV="`cat /etc/mousedevice`"
  20. case $DETECTEDMOUSEDEV in
  21. ttyS*)
  22. MOUSEMENU1a=$(gettext 'serial'); MOUSEMENU1b=$(gettext '(mouse in very old computers)')
  23. MOUSEMENU2a=$(gettext 'usb/ps-2'); MOUSEMENU2b=$(gettext '(mouse or touchpad in all modern computers)')
  24. ;;
  25. *)
  26. MOUSEMENU1a=$(gettext 'usb/ps-2'); MOUSEMENU1b=$(gettext '(mouse or touchpad in all modern computers)')
  27. MOUSEMENU2a=$(gettext 'serial'); MOUSEMENU2b=$(gettext '(mouse in very old computers)')
  28. ;;
  29. esac
  30. H_mc=$(gettext 'MouseCheck: choose interface')
  31. H_mt=$(gettext 'Please choose mouse type...') #111021
  32. pupdialog --background '#FFFF00' --ok-label "${B_ok}" --cancel-label "${B_cancel}" --colors --backtitle "${H_mc}" --menu "${ALERTMSG1}\n\n${ALERTMSG2}\n\n${MOUSEINTRO}\n\n${H_mt}" 0 100 3 "$MOUSEMENU1a" "${TABCHAR}${MOUSEMENU1b}" "$MOUSEMENU2a" "${TABCHAR}${MOUSEMENU2b}" 2> /tmp/testmsx
  33. [ $? -ne 0 ] && return 1
  34. [ ! -s /tmp/testmsx ] && return 1
  35. CHOSENMOUSETYPE="`cat /tmp/testmsx`"
  36. case $CHOSENMOUSETYPE in
  37. serial)
  38. H_s=$(gettext 'MouseCheck: choose serial port')
  39. M_s=$(gettext 'Choose serial port mouse plugged into. \ZbUP/DOWN\ZB arrows then \ZbENTER\ZB key to choose interface, then \ZbTAB\ZB key to select the \ZbOK\ZB button, then ENTER')
  40. S_1=$(gettext '(most likely)')
  41. pupdialog --background '#FFFF00' --ok-label "${B_ok}" --cancel-label "${B_cancel}" --colors --backtitle "${H_s}" --menu "${M_s}" 0 100 5 ttyS0 "COM1 ${S_1}" ttyS1 COM2 ttyS2 COM3 ttyS3 COM4 2> /tmp/testmsx
  42. [ $? -ne 0 ] && return 1
  43. [ ! -s /tmp/testmsx ] && return 1
  44. MOUSEDEV="`cat /tmp/testmsx`"
  45. modprobe sermouse
  46. ln -snf $MOUSEDEV /dev/mouse
  47. echo -n "$MOUSEDEV" > /etc/mousedevice
  48. sed -i -e 's/\W\+Option\W\+"Protocol"\W\+"\(\(\w\+\/\w\+\)\|\(\w\+\)\)\W\+#mouse0protocol/ Option "Protocol" "Microsoft" #mouse0protocol/' /etc/X11/xorg.conf
  49. ;;
  50. *)
  51. echo -n "input/mice" > /etc/mousedevice
  52. ln -snf input/mice /dev/mouse
  53. sed -i -e 's/\W\+Option\W\+"Protocol"\W\+"\(\(\w\+\/\w\+\)\|\(\w\+\)\)\W\+#mouse0protocol/ Option "Protocol" "IMPS\/2" #mouse0protocol/' /etc/X11/xorg.conf
  54. ;;
  55. esac
  56. return 0
  57. } #choosemousefunc()
  58. if [ "$PARAM1" != "nowait" ];then #111026
  59. CURPOS1="`getcurpos`"
  60. sleep 5
  61. CURPOS2="`getcurpos`"
  62. [ "$CURPOS1" != "$CURPOS2" ] && exit 0
  63. sleep 6
  64. CURPOS2="`getcurpos`"
  65. [ "$CURPOS1" != "$CURPOS2" ] && exit 0
  66. /usr/lib/gtkdialog/box_splash -icon /usr/share/pixmaps/puppy/mouse.svg -bg red -placement center -close never -fontsize x-large -text "$(gettext 'Your mouse has not moved, does it work? Please move it now. If your mouse does not work, just wait, in 10 seconds a window (usable by the keyboard) will pop up and enable you to fix the mouse.')" &
  67. YPID=$!
  68. mCNT=0
  69. while [ $mCNT -lt 11 ];do
  70. sleep 2
  71. CURPOS2="`getcurpos`"
  72. if [ "$CURPOS1" != "$CURPOS2" ];then
  73. kill $YPID
  74. exit 0
  75. fi
  76. mCNT=`expr $mCNT + 2`
  77. done
  78. kill $YPID
  79. #...failure
  80. fi
  81. choosemousefunc
  82. if [ $? -eq 0 ];then
  83. echo -n '' > /tmp/delayedrun_quicksetup_count #111026 hack for 'delayedrun', so quicksetup will re-run.
  84. rm -rf /tmp/.X0-lock
  85. sync
  86. exec restartwm
  87. fi
  88. ###END###