#!/bin/sh

start_qml() {
    cd /opt/FeedingIt
    python2.5 FeedingIt-Web.py 2>&1 >/dev/null &
    pid=`pidof python2.5 FeedingIt-Web.py`
    sleep 1
    qmlviewer -opengl -fullscreen qml/FeedingIt.qml
    kill $pid
}
start_gtk() {
	cd /opt/FeedingIt
    python2.5 FeedingIt.py
}


case "$1" in
update)
    dbus-send --print-reply --dest='org.marcoz.feedingit' --session /org/marcoz/feedingit/update org.marcoz.feedingit.UpdateAll
    ;;
status)
    dbus-send --print-reply --dest='org.maemo.feedingit' --session /org/maemo/feedingit org.maemo.feedingit.GetStatus
    ;;
dbus)
	cd /opt/FeedingIt
	#cp feedingit_status.desktop /usr/share/applications/hildon-status-menu/
	nice python2.5 update_feeds.py --daemon
	;;
noqml)
	start_gtk
    ;;
qml)
	start_qml
	;;
*)
	start_gtk
    ;;
esac
