CF-72 Touchscreen script 2.1
I recently upgraded updated my notebook to Ubuntu 9.10 Karmic Koala. For the most part it went well, as is to be expected with a clean install. For a while now I have just backed up my home directory and reinstalled rather then doing upgrades – its just a smoother ride. Perhaps the biggest hiccup was getting the touchscreen working again. The script I wrote for 9.o4 kept stalling out halfway through. It wouldn’t even tell why, it would just stop responding and I would have to escape out at the terminal. I futzed around with it for a little while and then noticed that the touch screen was working. So while something was going wrong and I never really found out what, it did eventually take.
I finally got back to the script; I first went through it editing it for readability and then tweaked a few things I had broken with my futzing, finally I added sudo in-line so the script can be launched by any user with sudo privileges. I never did figure out what had happened; there are no major differences between this script and the last one so they ought to be inter changeable. Anyway at long last pstouchscreen-2.1.sh
** edit — fixed some mistakes and advanced to v 2.1
#!/bin/bash # script builds and installs a custom touchscreen module for CF-72 toughbook # script variables kernNum=`uname -r` # for checking kernel source version kernNum=${kernNum:0:6} # <--- number matches current kernel workingDirectory="/tmp/mouse" # Compile in temp directory easy cleanup psmE="/tmp/psm_error.txt" psmL="/tmp/psm_log.txt" scriptLocation=`find ~/ -name ps2touchscreen.sh` # locate the script mouseDir="/lib/modules/`uname -r`/kernel/drivers/input/mouse" #this is a processing indicator (aka spinner) isWorking() { i=1 sp="/-\|" echo -n ' ' while [ -n "`pgrep $processing`" ] do sleep 0.01 printf "\b${sp:i++%${#sp}:1}" done errorCheck } # error checking routine errorCheck() { errors=`cat $psmE` if [ -n "$errors" ]; then echo " ##################################################### ## ## ## The Following Errors were ecountered! ## ## ## ##################################################### " cat $psmE exit 0 else echo -e \\b" done " fi } installScreen() { gksudo ls >> /dev/null 2>&1 pq="n" # user input variable default value if [ -e $psmL ]; then rm $psmE $psmL fi # checking for and installing any required packages pkgString="" echo "** Checking for required packages . . . " if [ -e "/usr/lib/xorg/modules/input/evtouch_drv.so" ]; then echo "** evtouch driver . . . . . . . . . . . . present" else pkgString="xserver-xorg-input-evtouch " fi if [ -e "/usr/src/linux-source-"$kernNum".tar.bz2" ]; then echo "** linux-source-"$kernNum" . . . . . . . . . present" else pkgString=$pkgString"linux-source " fi if [ -e "/usr/src/linux-headers-`uname -r`/Makefile" ]; then echo "** linux-headers-`uname -r`. . . . present" else pkgString=$pkgString"linux-headers-`uname -r` " fi if [ -n "$pkgString" ]; then echo ">> The following packages need to be installed :\n\t"$pkgString"\n" echo -n "press i to install or q to quit : " until [ $pq = "i" ]; do read -a pq -n 1 if [ $pq == "q" ]; then exit 0 fi done sudo apt-get -y install $pkgString 1>>$psmL 2>>$psmE & processing=apt-get isWorking else echo "** All of the necessary packages are present" fi # remove incompatible video driver if [ -e "/usr/lib/xorg/modules/drivers/fglrx_drv.so" ]; then echo ">> The ATI fglrx driver is incompatible with\n the xorg-input-evtouch touchscreen driver\n" read -a pq -sn 1 -p ">> press u to uninstall or q to quit " until [ $pq = "u" ]; do if [ $pq = "q" ]; then exit 0 fi done echo -n "** Removing ATI fglrx graphics driver . . . ." sudo apt-get remove xorg-driver-fglrx 1>>$psmL 2>>$psmE & processing=apt-get isWorking fi # Check kernel source version - extract if necessary if [ -e "/usr/src/linux-source-$kernNum" ]; then echo "** Linux Source is up-to-date" else echo -n "** Extracting Linux Source, please wait . . . " cd /usr/src sudo tar -xjf "linux-source-"$kernNum".tar.bz2" 1>>$psmL 2>>$psmE & processing="tar" isWorking fi echo "** Preparing the driver source code for the compiler" cp -R /usr/src/linux-source-$kernNum/drivers/input/mouse /tmp sleep 2 cd $workingDirectory sleep 3 # repair the CF-72 entry in the source file sed -i ' /.*"CF-72"),/ {; n; n; N s/.*serio3\",/\t\t.callback\ =\ lifebook_set_6byte_proto,/ }' $workingDirectory/lifebook.c echo '''# # Makefile for the psmouse driver. # obj-m := psmouse.o psmouse-objs := psmouse-base.o synaptics.o alps.o lifebook.o trackpoint.o \ logips2pp.o elantech.o hgpk.o all: $(MAKE) -C /lib/modules/`uname -r`/build M=`pwd` modules clean: $(MAKE) -C /lib/modules/`uname -r`/build M=`pwd` clean $(RM) Module.markers modules.order ''' >Makefile echo -n "** Compiling the PS/2 Touchscreen driver . . . " make 1>>$psmL 2>>$psmE & processing="make" isWorking echo "** Touchscreen driver compiled successfully!" echo ">> Press any key to install the new driver" read -sn 1 echo "** Installing touchscreen driver . . . " sudo mv $mouseDir/psmouse.ko $mouseDir/psmouse.bak 1>>$psmL 2>>$psmE sudo cp $workingDirectory/psmouse.ko $mouseDir/psmouse.ko 2>>$psmE sudo rmmod psmouse && sudo modprobe psmouse 1>>$psmL 2>>$psmE make clean 1>>$psmL 2>>$psmE errorCheck # the driver has been successfully installed now clean up rm -R $workingDirectory echo "** Touchscreen driver successfully installed!" echo " >> If this is the first time this script has been run the touchscreen now needs to be configured. Otherwise you can safely exit the program now. >> press c to configure or q to quit" until [ $pq = "c" ]; do read -a pq -n 1 if [ $pq == "q" ]; then exit 0 fi done # backup and remove /etc/X11/xorg.conf it is no longer needed if [ -e "/etc/X11/xorg.conf" ]; then echo "** Backing up old xorg configuration " sudo mv /etc/X11/xorg.conf /etc/X11/xorg-`date +%I%M%m%d%Y`.conf fi # create /etc/hal/fdi/policy/10-x11-input.fdi for hal echo '''<?xml version="1.0" encoding="UTF-8"?> <!-- -*- SGML -*- --> <!-- Pointer inputs for the Panasonic CF-72 w/ Touchscreen. Models without touchscreen do not need this file, they are automatically configured by hal --> <deviceinfo version="0.2"> <device> <match key="info.product" contains="LBPS/2 Fujitsu Lifebook TouchScreen"> <merge key="input.x11_driver" type="string">evtouch</merge> <merge key="input.x11_options.Device" type="string">/dev/input/by-path/platform-i8042-serio-1-event-mouse</merge> <merge key="input.x11_options.ReportingMode" type="string">Raw</merge> <merge key="input.x11_options.MinX" type="string">240</merge> <merge key="input.x11_options.MinY" type="string">220</merge> <merge key="input.x11_options.MaxX" type="string">3900</merge> <merge key="input.x11_options.MaxY" type="string">3800</merge> <merge key="input.x11_options.MoveLimit" type="string">5</merge> <merge key="input.x11_options.SendCoreEvents" type="string">true</merge> </match> </device> </deviceinfo>'''>/tmp/input.fdi sudo mv /tmp/input.fdi /etc/hal/fdi/policy/10-x11-input.fdi sudo rmmod psmouse && sudo modprobe psmouse 1>>$psmL 2>>$psmE errorCheck # last error check makes sure driver loaded and then final cleanup rm $psmL $psmE echo " ** Touchscreen configuration complete ! It may be necessary to reboot the computer before the touchscreen configuration is loaded." read -a pq -sn 1 -p ">> press r to reboot or q to quit " until [ $pq = "r" ]; do if [ $pq = "q" ]; then exit 0 fi done reboot exit 0 } installScreen
