#!/bin/sh
rm -f  /tmp/gxineerror.log 2>/dev/null

#v3.99 bugfix: when a file with full path, prefix with file://
PREFILE=''
#[ "`echo "$@" | grep ':/'`" = "" ] && [ -f "$@" ] && PREFILE='file://'
[ "`echo "$@" | cut -b 1`" = "/" ] && [ -f "$@" ] && PREFILE='file://'

SCRNSAVE=`xset q | grep "timeout:" | tr -s " " | cut -f 3 -d " "`
if [ $SCRNSAVE -ne 0 ];then
 xset s off -dpms #v426 bugfix
 gxine ${PREFILE}"$@" 2> /tmp/gxineerror.log
 xset s on +dpms #v426
else
 gxine ${PREFILE}"$@" 2> /tmp/gxineerror.log
fi

if [ -s /tmp/gxineerror.log ];then
 if [ ! "`grep 'Error loading library' /tmp/gxineerror.log`" = "" ];then
  if [ "`cat /root/.packages/packages.txt /root/.packages/livepackages.txt | grep '"mplayer_codecs_full' | grep '" on "'`" = "" ];then #'Geany
   xmessage -center -bg '#FF8080' -title "Gxine ERROR" "Gxine failed to load a codec file required to play the media file.
There is a PET package with extra codecs, called 'mplayer_codecs_full'.
Please run the PETget package manager and install it -- click the
'install' button on the desktop or run from the 'Setup' menu."
  fi
 fi
fi

###END###
