#!/bin/bash
# defaults
+profiles=/etc/pandora/conf/tvout-profiles.conf
tv_type="pal"
conn_type="svideo"
layer=0
echo 1 > overlay0/enabled
}
+is_good_tv_type()
+{
+ if [ "$1" == "pal" -o "$1" == "ntsc" ]; then
+ return 0
+ fi
+ echo "bad tv_type: $1"
+ false
+}
+
+is_good_conn_type()
+{
+ if [ "$1" == "svideo" -o "$1" == "composite" ]; then
+ return 0
+ fi
+ echo "bad conn_type: $1"
+ false
+}
+
+is_good_layer()
+{
+ if [ "$1" == "0" -o "$1" == "1" ]; then
+ return 0
+ fi
+ echo "bad layer: $1"
+ false
+}
+
+# read defaults from user profile
+if test -f "$profiles"; then
+ defprofile=`grep -A1 '^Last written' "$profiles" | tail -n 1`
+ if test -n "$defprofile"; then
+ parse_profile()
+ {
+ # enabled
+ # encoding
+ is_good_tv_type $2 && tv_type=$2
+ # connection
+ is_good_conn_type $3 && conn_type=$3
+ # layer
+ is_good_layer $4 && layer=$4
+ # x,y
+ test -n "$5" -a -n "$6" && eval ${tv_type}_pos=$5,$6
+ # w,h
+ test -n "$7" -a -n "$8" && eval ${tv_type}_size=$7,$8
+ }
+
+ parse_profile $defprofile
+ echo "loaded defaults from last used profile"
+ fi
+fi
+
# parse args
got_args=false
while true; do
got_args=true
done
-if [ "$tv_type" != "pal" -a "$tv_type" != "ntsc" ]; then
+if ! is_good_tv_type $tv_type; then
usage
fi
-if [ "$conn_type" != "svideo" -a "$conn_type" != "composite" ]; then
+if ! is_good_conn_type $conn_type; then
usage
fi
-if [ "$layer" != "0" -a "$layer" != "1" ]; then
+if ! is_good_layer $layer; then
usage
fi