CF-72 Touchscreen Script 0.2

New! improved! with 0.2% more intelligence!

Added features:

  • Checks that it is being run with proper permissions
  • Checks for necessary packages before trying to install them
  • Fine tuned /etc/X11/xorg.conf settings
  • Error checking!
  • Improved processing indicator
  • No longer kills gdm
  • Post install cleanup

All that is left to do is figure out sed multi-line pattern matching/editing and this thing will be done. Till then I will  continue to embed the psmouse.c and xorg.conf files in the script. Here it is:

#!/bin/bash
# this script builds a custom module for the touchscreen on pansonic CF-72 notebooks
# script variables
KernNum=`uname -r`    # for checking kernel source version
KernNum=${KernNum:0:6}     # /dev/null 2>/tmp/chkperm
CHKP=`cat /tmp/chkperm`
if [ -n "$CHKP" ]; then
	echo -e \\r"** You must have root permission to execute this script, try:
	sudo "$ScriptL
	rm /tmp/chkperm
exit 0
else # clean up possible previous attempts
	rm /root/psm_log.txt >/dev/null 2>&1
	rm /root/psm_error.txt >/dev/null 2>&1
# checking for and installing any required packages
PkgStrng=""
echo -e \\r"** Checking for required packages . . . "
if [ -e "/usr/lib/xorg/modules/input/evtouch_drv.so" ]; then
	echo -e \\r"** evtouch driver . . . . . . . . . . . . present"
else
	PkgStrng="xserver-xorg-input-evtouch "
fi
if [ -e "/usr/src/linux-source-"$KernNum".tar.bz2" ]; then
	echo -e \\r"** linux-source-"$KernNum"  . . . . . . . . . present"
else
	PkgStrng=$PkgStrng"linux-source "
fi
if [ -e "/usr/src/linux-headers-`uname -r`/Makefile" ]; then
	echo -e \\r"** linux-headers-`uname -r`. . . . present"
else
	PkgStrng=$PkgStrng"linux-headers-`uname -r` "
fi
if [ -n $PkgStrng ]; then
	echo -e \\r"** All of the necessary packages are present"
else
	echo -en \\r"** Installing "$PkgStrng" . . . "
	apt-get -y install $PkgStrng 1>>/root/psm_log.txt 2>>/root/psm_error.txt &
	RUNNING=apt-get
	IsWorking
fi
if [ -e "/usr/lib/xorg/modules/drivers/fglrx_drv.so" ]; then
	echo -n \\r"** Removing ATI fglrx graphics driver . . . ."
	apt-get remove xorg-driver-fglrx 1>>/root/psm_log.txt 2>>/root/psm_error.txt &
	RUNNING=apt-get
	IsWorking
fi
# Check kernel source version - extract if necessary
if [ -e "/usr/src/linux-source-$KernNum" ]; then
	echo -e \\r"** Linux Source is up-to-date"
else
	echo -en \\r"** Extracting Linux Source, please wait . . . "
cd /usr/src
tar -xjf "linux-source-"$KernNum".tar.bz2" 1>>/root/psm_log.txt 2>>/root/psm_error.txt &
RUNNING="tar"
IsWorking
fi
# fix the psmouse.c file this is why we are here
# I plan on replacing this next part as soon as I
# figure out sed multi-line partern matching/editing
echo -e \\r"** Preparing the driver source code for the compiler"
mkdir $CompDir 1>>/root/psm_log.txt 2>>/root/psm_error.txt &
cp -R /usr/src/linux-source-$KernNum/drivers/input/mouse /tmp
cd $CompDir
mv $CompDir/lifebook.c $CompDir/lifebook.old 1>>/root/psm_log.txt 2>>/root/psm_error.txt
echo '''/*

This is where the psmouse.c source file goes. Remember to change

.callback = lifebook_set_serio_phys,
.driver_data = “isa0060/serio3”,

to:

.callback = lifebook_set_6byte_proto,

in the CF-72 stanza

''' >lifebook.c
mv ./Makefile ./Makefile.old
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 -en \\r"** Compiling the PS/2 Touchscreen driver . . . "
make 1>>/root/psm_log.txt 2>>/root/psm_error.txt &
RUNNING="make"
IsWorking
echo -e \\r"** Driver compiled successfully!"
echo -e \\n\\r"+-------------------------------------------------+
|  After installation of the touch screen driver  |
|  the X server will be reset, please save your   |
|  work and close all other open windows.         |
+-------------------------------------------------+"
read -sn 1 -p "** Press any key to continue. . ."
echo -e \\n\\r"** Installing touchscreen driver . . . "
sleep 5
mv /lib/modules/`uname -r`/kernel/drivers/input/mouse/psmouse.ko /lib/modules/`uname -r`/kernel/drivers/input/mouse/psmouse.bak 1>>/root/psm_log.txt 2>>/root/psm_error.txt
cp $CompDir/psmouse.ko /lib/modules/`uname -r`/kernel/drivers/input/mouse/psmouse.ko 1>>/root/psm_log.txt 2>>/root/psm_error.txt
make clean 1>>/root/psm_log.txt 2>>/root/psm_error.txt
ErrChck
rm -R $CompDir
mv /etc/X11/xorg.conf /etc/X11/xorg-`date +%I%M%m%d%Y`.conf 1>>/root/psm_log.txt 2>>/root/psm_error.txt
echo ''
# xorg.conf (X.Org X Window System server configuration file)
#
# This file was generated by dexconf, the Debian X Configuration tool, using
# values from the debconf database.
#
# Edit this file with caution, and see the xorg.conf manual page.
# (Type "man xorg.conf" at the shell prompt.)
#
# This file is automatically updated on xserver-xorg package upgrades *only*
# if it has not been modified since the last upgrade of the xserver-xorg
# package.
#
# Note that some configuration settings that could be done previously
# in this file, now are automatically configured by the server and settings
# here are ignored.
#
# If you have edited this file but would like it to be automatically updated
# again, run the following command:
#   sudo dpkg-reconfigure -phigh xserver-xorg

Section "Module"
Load "i2c"
Load "bitmap"
Load "ddc"
Load "dri"
Load "extmod"
Load "freetype"
Load "glx"
Load "GLcore"
Load "int10"
Load "type1"
Load "vbe"
EndSection

Section "InputDevice"
	Identifier 	"Generic Keyboard"
	Driver 		"kbd"
	Option 		"CoreKeyboard"
	Option 		"XkbRules" "xorg"
	Option 		"XkbModel" "pc105"
	Option 		"XkbLayout" "us
	Option 		"XkbOptions" "lv3:ralt_switch"
EndSection

Section "InputDevice"
	Identifier 	"touchscreen"
	Driver 		"evtouch"
	Option 		"Device" "/dev/input/by-path/platform-i8042-serio-1-event-mouse"
	Option 		"DeviceName" "touchscreen"
	Option 		"MinX" "230" #"230"
	Option 		"MinY" "220" #"220"
	Option 		"MaxX" "3900" #"3900"
	Option 		"MaxY" "3850" #"3850"
	Option		"MoveLimit"	"5"
	Option 		"ReportingMode" "Raw"
	Option 		"SendCoreEvents" "true"
	Option 		"Emulate3Buttons" "true"
	Option 		"Emulate3Timeout" "40"
EndSection

Section "InputDevice"
	Identifier 	"Synaptics Touchpad"
	Driver 		"mouse"
	Option 		"Mode" "Relative"
	Option 		"CorePointer" "true"
	Option 		"Device" "/dev/input/mice"
	Option 		"Protocol" "ExplorerPS/2"
	Option 		"Emulate3Buttons" "true"
	#Option 	"HorizScrollDelta" "0"
EndSection

Section "Device"
	Identifier	"Configured Video Device"
EndSection

Section "Monitor"
	Identifier	"Configured Monitor"
EndSection

Section "Screen"
	Identifier	"Default Screen"
	Monitor		"Configured Monitor"
	Device		"Configured Video Device"
EndSection

Section "ServerLayout"
	Identifier 	"Default Layout"
	Screen 		"Default Screen"
	InputDevice 	"Generic Keyboard"
	InputDevice 	"Synaptics Touchpad" "CorePointer"
	InputDevice 	"touchscreen" "SendCoreEvents"
EndSection

Section "DRI"
Mode 0666
EndSection '''>/etc/X11/xorg.conf
ErrChck
rmmod psmouse 1>>/root/psm_log.txt 2>>/root/psm_error.txt
sleep 2
modprobe psmouse 1>>/root/psm_log.txt 2>>/root/psm_error.txt
sleep 2
rm -R /tmp/mouse
/etc/init.d/gdm restart
fi
exit 0

This post is outdated please use the new script here

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s