%
% anyremote configuration file for kmplayer management.
% prerequisites: KDE, kmplayer, amixer utility (example is for soundcard)
%  $MOVIE_DIR environment variable
%

% STATUS stable
% XTEST no
% SOUND app
% ENV no

GuiAppName=Kmplayer
GuiAppBinary=kmplayer
GuiAppRun=echo 'A=`dcop 2> /dev/null|grep kmplayer`; if [ "x$A" == "x" ]; then echo NOK; else echo OK; fi'|bash -f -s
GuiAppIcon=kmplayer.png
GuiAppType=Application
GuiAppProtocols=AT
GuiAppDesc=Media Player for KDE
GuiAppVersion=echo 'V=`kmplayer -v|grep KDE|tr -d " "|cut -f 2 -d ":"|cut -f 1 -d "."`; if [ "x$V" == "x3" ]; then echo OK; else echo NOK; fi'|bash -f -s

[Protocol]=AT

(Init)=Include($(CfgDir)/Utils/aliases-at.cfg);\
	Make(var,TwoWayComm,by_value,false);\
	Make(var,Device,by_value,/dev/rfcomm0);\
	Exec(echo 'V=`amarok -v|grep KDE|tr -d " "|cut -f 2 -d ":"|cut -f 1 -d "."`; if [ "x$V" == "x4" ]; then $(CfgDir)/Utils/message.sh "ERROR: this configuration file is for KDE3"; fi'|bash -f -s);\
	Exec(echo 'if [ "x$MOVIE_DIR" == "x" ]; then $(CfgDir)/Utils/message.sh "ERROR: MOVIE_DIR environment variable is not set !"; fi'|bash -f -s);

Cancel=\
    Exec(echo 'K=`dcop|grep kmplayer`;dcop $K MainApplication-Interface quit'|bash -f -s);\
	SendCKPD(E);

KLAYER_RESET=Make(var,kmplayer_list,by_value);\
	Exec(echo 'K=`dcop|grep kmplayer`;if [ "x$K" == "x" ]; then kmplayer& fi;'|bash -f -s)

(Connect)=Macro(KLAYER_RESET)

1=Exec(amixer sset Master,0 5%-    -q)
2=Exec(amixer sset Master,0 toggle -q)
3=Exec(amixer sset Master,0 5%+    -q)

4=Exec(echo 'K=`dcop|grep kmplayer`;POS=`dcop $K KMediaPlayer position`;NEWPOS=`expr $POS - 10000`;dcop $K KMediaPlayer seek $NEWPOS'|bash -f -s)
5=Make(var,kmplayer_list,echo 'K=`dcop|grep kmplayer`;P=`dcop $K KMediaPlayer isPlaying`; if [ "x$P" == "xtrue" ]; then true; else NUM=$(kmplayer_list);if [ "x$(kmplayer_list)" == "x" ]; then NUM=1; fi; dcop $K KMediaPlayer openURL `find $MOVIE_DIR -type f|head -$NUM|tail -1`;echo $NUM; fi'|bash -f -s|tail -1)
6=Exec(echo 'K=`dcop|grep kmplayer`;POS=`dcop $K KMediaPlayer position`;NEWPOS=`expr $POS + 10000`;dcop $K KMediaPlayer seek $NEWPOS'|bash -f -s)

7=Make(var,kmplayer_list,echo 'K=`dcop|grep kmplayer`;if [ "x$(kmplayer_list)" == "x" ] || [ "x$(kmplayer_list)" == "x0" ] || [ "x$(kmplayer_list)" == "x1" ]; then NUM=1; else NUM=`expr $(kmplayer_list) - 1`; fi; dcop $K KMediaPlayer openURL `find $MOVIE_DIR -type f|head -$NUM|tail -1`;echo $NUM'|bash -f -s|tail -1)
8=Exec(dcop `dcop|grep kmplayer` KMediaPlayer stop)
9=Make(var,kmplayer_list,echo 'K=`dcop|grep kmplayer`;if [ "x$(kmplayer_list)" == "x" ]; then NUM=1; else NUM=`expr $(kmplayer_list) + 1`;fi; dcop $K KMediaPlayer openURL `find $MOVIE_DIR -type f|head -$NUM|tail -1`;echo $NUM'|bash -f -s|tail -1)

* *=Exec(echo 'F="$HOME/.anyRemote/anyrem.hlp";echo "1 - Vol-    2 - Mute  3 - Vol+  " > $F;echo "4 - Rew     5 - Play  6 - FF" >> $F;echo "7 - Prew    8 - Stop  9 - Next" >> $F;echo "* * - Help  0 - Pause # - Quit" >> $F;kdialog -passivepopup "`cat $F`" 7' |bash -f -s)
* 1=Macro(KLAYER_RESET)
* #=Exec(echo 'K=`dcop|grep kmplayer`;if [ "x$K" == "x" ]; then kmplayer& else dcop $K MainApplication-Interface quit; fi;'|bash -f -s)
0=Exec(dcop `dcop|grep kmplayer` KMediaPlayer pause)
#=Exec(echo 'K=`dcop|grep kmplayer`;dcop $K MainApplication-Interface quit'|bash -f -s)

[End]
