#!/bin/bash
# AQ
# 20120913

killall GT_service
ports=`sudo /bin/cat /proc/tty/driver/serial | grep " uart:[A-Z0-9][^\s]* " | awk '{print $1}' | sed -n 's/\([0-9]\)\+.*/COM\1/p'`
ports=`echo $ports | sed 's/COM/false COM/g'`
port=$(zenity --title='GeneralTouch calibration' --text='On what port is the screen connected to?' --list --checklist --column='' --column='' $ports)
port=`echo $port | sed 's/COM//'`
echo "Port $port"

file="$HOME/.config/autostart/GT_service.desktop"
echo "[Desktop Entry]" > $file
echo "Type=Application" >> $file
echo "Name=GentralTouch Service" >> $file
echo "Exec=/usr/local/Gentouch_S/GT_service restart" >> $file
chmod 644 $file

/usr/local/Gentouch_S/GTscal /dev/ttyS$port
