%
% anyremote configuration file for juk management (Server-mode Bemused emulation)
% Prerequisites: Bemused client installed on cell phone
%

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

GuiAppName=Juk
GuiAppBinary=juk
GuiAppRun=echo 'A=`dcop 2> /dev/null|grep juk`; if [ "x$A" == "x" ]; then echo NOK; else echo OK; fi'|bash -f -s
GuiAppIcon=juk.png
GuiAppType=Application
GuiAppProtocols=Bemused
GuiAppDesc=JuK is a free software audio player for KDE, part of the kdemultimedia package. JuK supports collections of MP3, Ogg Vorbis, and FLAC audio files. This configuration file is for Juk/KDE3.

[Protocol]=Bemused

(Init)=Include($(CfgDir)/Utils/aliases-bemused.cfg);
(Connect)=Make(mode,juk);

[Mode]=juk

(EnterMode)=Exec(echo 'A=`dcop|grep juk`; if [ "x$A" == "x" ]; then juk; fi'|bash -f -s);

EXIT=Exec(dcop juk MainApplication-Interface quit)
FADE=Exec(dcop juk Player mute)
FFWD=Exec(echo 'T=`dcop juk Player currentTime`;T2=`expr $T + 5`;dcop juk Player seek $T2'| bash -f -s)
INF2=Send(string,INF2ACK);Send(bytes,128,0,0,0,128,0,0,0,1,0,0);ExecAndSend(string,dcop juk Player playingString);Send(bytes,0,0)
INFO=Send(string,INFOACK);Send(bytes,128,0,0,0,128,0,0,0,1,0,0);ExecAndSend(string,dcop juk Player playingString)
NEXT=Exec(dcop juk Player forward)
PAUS=Exec(dcop juk Player playPause)
PLAY=Exec(dcop juk Player play)
PREV=Exec(dcop juk Player back)
RWND=Exec(echo 'T=`dcop juk Player currentTime`;T2=`expr $T + 5`;dcop juk Player seek $T2'| bash -f -s)
STOP=Exec(dcop juk Player stop)
VOLM($$)=Exec(dcop juk Player setVolume `echo "$(Param)"|awk '{print $0/100;}'`);

%GVOL=Send(string,GVOLNAK)
GVOL=Send(string,GVOLACK);Make(var,j_volume,echo 'V=`dcop juk Player volume`;echo "$V*255"|bc|cut -f 1 -d "."'|bash -f -s);Send(bytes,$(j_volume))

PLEN=ExecAndSend(bytes,dcop juk Collection playlistTracks `dcop juk Collection playlist`|wc -l|awk '{if($0>255) {b=int($0/256);a=$0-b;} else {b=$0;a=0};s=sprintf("%s,%s",a,b);print s;}');
PLST=Send(string,PLSTACK);\
	Send(bytes,0,1);\
	ExecAndSend(string,echo 'L=`dcop juk Collection playlist`;dcop juk Collection playlistTracks "$L" > $HOME/.anyRemote/juk.playlist'|bash -f -s;cat $HOME/.anyRemote/juk.playlist|xargs -i -d '\n' basename {});\
	Send(bytes,0);
SLCT($$)=Exec(echo 'X=`echo "$(Param)+1"|bc`;F=`head -$X $HOME/.anyRemote/juk.playlist|tail -1`;dcop juk Player play "$F"'| bash -f -s);

%REPT=Exec()
%SHFL=Exec()

% The following is a trick. Replays are not real, just to satisfy client.
CHCK=Send(string,Y);
DINF=Send(string,DINFACK);Send(bytes,0,0,0,244,0,0,32,0,0,0,0,2);
DLST=Send(bytes,255,0)
DOWN=Send(bytes,0,100);Send(string,NoName)
FINF=Send(string,FINFACK);Send(bytes,0,0,0,100);
LIST=Send(bytes,255,0)
PLEN=Send(bytes,0,100)
PLST=Send(string,PLSTACK);Send(bytes,0,1,35,10);Send(string,NoName);Send(bytes,10,0)
%SEEK=
%SLCT=
VERS=Send(string,VERSACK);Send(bytes,1,73);

[ModeEnd]

[End]
