#!/bin/sh
#
# fluxbox startup-script:
#
# Lines starting with a '#' are ignored.

# Change your keymap:
xmodmap "/root/.Xmodmap"

for device in `xrandr -q | grep connected | cut -d" " -f1`; do
  xrandr --output $device --mode 800x600 --pos 0x0 --rotate normal
done

TOUCH_DEV1=`xinput --list | grep id= | grep IDEACO | head -1 | cut -f2 -d"=" | cut -f1`
TOUCH_DEV2=`xinput --list | grep id= | grep IDEACO | tail -1 | cut -f2 -d"=" | cut -f1`

# from both input devices, try to guess which one is the touchscreen
IS_DEV1=`xinput --list-props $TOUCH_DEV1 | grep "Abs Pressure"`
IS_DEV2=`xinput --list-props $TOUCH_DEV2 | grep "Abs Pressure"`

TOUCH_DEV=0

if [ "$IS_DEV1" != "" ]; then
  TOUCH_DEV=$TOUCH_DEV1
elif [ "$IS_DEV2" != "" ]; then
  TOUCH_DEV=$TOUCH_DEV2
fi

##COORDINATES##

# x11vnc
/usr/bin/x11vnc -notruecolor -norc -forever -scale 800x600 -geometry 800x600 -bg -display :0

# run pos
/opt/pos/common/bin/run_pos.sh &

exec fluxbox

