#!/bin/sh

# removefile.sh
# Uninstall
#
# Created by Smith_yang on 09-2-23.
# Copyright 2009 __MyCompanyName__. All rights reserved.


#killall SharpTouchDisplayDriver 
#killall SharpTouchDisplaySettingUtility 

killall "SharpTouchDisplayDriver" || echo "No killprocess"
killall "SharpTouchDisplaySettingUtility" || echo "No killprocess"
killall "System Preferences" || echo "No killprocess"
#sleep 3


echo $1
echo "The uninstaller will be uninstall the SharpTouchDisplayDriver all files."
echo $2
#PERL = echo $2

sudo chown root:wheel $2



case $1 in
	1) echo "1 time"
		$2
		#perl $PERL
		rm -f -R   /Library/PreferencePanes/SharpTouchDisplay.prefPane
		;;
	5) echo "2 times"
		rm -f -R /Library/LaunchAgents/com.newsoft.touchDisplay.plist
		;;
	10) echo "3 times"
		rm -f -R /Library/Preferences/SharpTouchDisplay
		rm -f -R ~/Library/Preferences/SharpTouchDisplay
		sudo rm -rf -R /Library/Preferences/SharpTouchDisplay
		sudo rm -rf -R ~/Library/Preferences/SharpTouchDisplay
		;;
	20) echo "4 times"
		#remove the TouchDisplayDriver.kext
		kextunload /System/Library/Extensions/TouchDisplayDriver.kext
	    kextunload /Library/Extensions/TouchDisplayDriver.kext
		rm -f -R  /System/Library/Extensions/TouchDisplayDriver.kext
		rm -f -R  /Library/Extensions/TouchDisplayDriver.kext
        rm -r -f -R /private/var/root/Library/Preferences/SharpTouchDisplay
        sudo rm -r -f -R /private/var/root/Library/Preferences/SharpTouchDisplay    
		;;
	30) echo "5 times"		
		rm -rf -R /Library/Application\ Support/SharpTouchDisplay
		sudo rm -r -f -R /Library/Application\ Support/SharpTouchDisplay
        
		;;

esac

echo "SharpTouchDisplayDriver has remove the all files."