#!/bin/sh

. /etc/formfactor/config
. /etc/formfactor/appconfig

SHOWCURSOR="no"
KEYBOARD_APPLET="keyboard"
START_APPLETS=windowselector
HTTPD=/home/root/RobotHttp/httpRobot
HTTPD_ARGS=/home/root/RobotHttp

if [ "$WM_LOAD_DESKTOP" = "yes" ]; then
	matchbox-desktop &
	START_APPLETS=$START_APPLETS,showdesktop
fi

if [ "$WB_LOAD_STARTUP" = "yes" ]; then
	WB_CFG=""

	if [ "$WB_LOAD_FULLSCREEN" = "yes" ]; then
		WB_CFG=$WB_CFG" -e Fullscreen"
	fi
	
	if [ "$WB_LOAD_WEBSITE" = "yes" ]; then
		WB_CFG=$WB_CFG" -a $WB_LOAD_URL"
	fi
	
	
	if [ "$WB_LOAD_FULLSCREEN" = "yes" ] || [ "$WB_LOAD_WEBSITE" = "yes" ]; then
		if [ "$WB_LOAD_MENUBAR" = "yes" ]; then
			WB_CFG=$WB_CFG" -e Menubar"
		fi
	
		if [ "$WB_LOAD_NAVBAR" = "yes" ]; then
			WB_CFG=$WB_CFG" -e Navigationbar"
		fi
	
		if [ "$WB_LOAD_STATUSBAR" = "yes" ]; then
			WB_CFG=$WB_CFG" -e Statusbar"
		fi
	fi
	
	midori $WB_CFG &
fi

if [ "$WM_LOAD_PANEL" = "yes" ]; then
	END_APPLETS=clock,launcher:matchbox-terminal,$KEYBOARD_APPLET
	matchbox-panel --titlebar --start-applets $START_APPLETS --end-applets $END_APPLETS &
fi

$HTTPD $HTTPD_ARGS &

exec matchbox-window-manager -theme Sato -use_desktop_mode decorated -use_titlebar $WM_LOAD_TITLEBAR -use_cursor $SHOWCURSOR $@
