#!/bin/sh

#   ALTLinux XawTV wrapper :
#   run scantv if there'sn't any config file
#   (c) 2001-2002 Thierry Vignaud <tvignaud@mandrakesoft.com> for MandrakeSoft
#   Released under the GNU GPL v2
#   Corrected Hihin Ruslan <hihin@narod.ru>

USER_RC=~/.tv/stations

if [ ! -e /etc/X11/xawtvrc -a ! -e $USER_RC ];then
    for path in /usr/bin/ /usr/bin/X11 /usr/sbin; do
	   if [[ -x $path/scantv ]]; then
		  altxtv=$path/scantv; break
	   fi
    done
    if [[ -z $altxtv ]]; then
	   if [[ -x /usr/bin/xvt ]]; then
		  alxtv="xvt -title 'Scanning for TV channels ...' -e scantv"
	   else  altxtv="scantv"
	   fi
    fi
    eval $altxtv
fi

# dynamic/hotplug run this scrit with webcams, thus scantv failled
touch $USER_RC
exec xawtv "$@"
