#!/bin/bash

found=0
lsusb | grep -q "1ddb:0001" 	
if [ $? -eq 0 ]; then
	found=1
fi
lsusb | grep -q "1bfd:1568" 	
if [ $? -eq 0 ]; then
	found=1
fi

account=`whoami`
if [ ${account} != "root" ]; then
	zenity --error --title="Touch calibration" --text="You must execute this script with sudo."
	echo " You must execute this script with sudo"
	echo ' '
	exit 1
fi

if [ -f /usr/local/bin/FreeDraw ]; then
	LinearAp 4
	rm -f /usr/share/X11/xorg.conf.d/99-calibration.conf
	rm -f /usr/share/X11/xorg.conf.d/Calibs
else
	if [ $found -eq 0 ]; then
		zenity --error --title="Touch calibration" --text="Risin touch controller not found!"
		echo 'Risin touch controller not found!'
		echo ' '
		exit 1
	else
		xinput_calibrator --misclick 0 --output-filename /usr/share/X11/xorg.conf.d/99-calibration.conf
	fi
fi
