From: Grazvydas Ignotas Date: Fri, 20 Sep 2013 23:07:26 +0000 (+0300) Subject: op_tvout: read defaults from profile X-Git-Tag: sz_160~50 X-Git-Url: https://git.openpandora.org/cgi-bin/gitweb.cgi?p=openpandora.oe.git;a=commitdiff_plain;h=23065e8ee2683cc0915b8ec0474e5935c37260b0 op_tvout: read defaults from profile --- diff --git a/recipes/pandora-system/pandora-scripts/op_tvout.sh b/recipes/pandora-system/pandora-scripts/op_tvout.sh index b10f748..e9ee540 100755 --- a/recipes/pandora-system/pandora-scripts/op_tvout.sh +++ b/recipes/pandora-system/pandora-scripts/op_tvout.sh @@ -1,6 +1,7 @@ #!/bin/bash # defaults +profiles=/etc/pandora/conf/tvout-profiles.conf tv_type="pal" conn_type="svideo" layer=0 @@ -74,6 +75,57 @@ disable_it() 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 @@ -129,15 +181,15 @@ 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