%
% anyremote configuration file for amarok management. (Server-mode Bemused emulation)
% Prerequisites: Bemused client installed on cell phone
% tested with Jam SE 1.3 RC1
%

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

GuiAppName=Amarok
GuiAppBinary=amarok
GuiAppVersion= V=`amarok -v|grep KDE|tr -d " "|cut -f 2 -d ":"|cut -f 1 -d "."`; if [ "x$V" = "x4" ]; then echo OK; else echo NOK; fi
GuiAppRun= A=`pgrep amarok`; if [ "x$A" = "x" ]; then echo NOK; else echo OK; fi
GuiAppIcon=amarok.png
GuiAppType=Application
GuiAppProtocols=Bemused
GuiAppDesc=Amarok is the music player for Linux and Unix with an intuitive interface. Amarok makes playing the music you love easier than ever before - and looks good doing it. This configuration file is for Amarok/KDE4

[Protocol]=Bemused

GETPOS=\
	Make(var,am_pos,qdbus org.kde.amarok /Player PositionGet);

GETVOL1=\
	Make(var,am_volume,qdbus org.kde.amarok /Player VolumeGet);

AMAROK_TITLE=\
	Make(var,art,qdbus org.kde.amarok /Player GetMetadata|grep artist:|sed 's/artist://');\
	Make(var,tit,qdbus org.kde.amarok /Player GetMetadata|grep title:|sed 's/title://');\
	Make(var,am_title,echo "$(art) - $(tit)");

(Init)=\
	Include($(CfgDir)/Utils/aliases-bemused.cfg);\
	Macro(BEMUSED_SETUP);\
	Exec(V=`amarok -v|grep KDE|tr -d " "|cut -f 2 -d ":"|cut -f 1 -d "."`;if [ "x$V" = "x3" ]; then $(CfgDir)/Utils/message.sh "ERROR: this configuration file is for KDE4"; fi);
	
(Connect)=\
	Exec(amarok 2> /dev/null);\
	Macro(GETVOL1);\
	Make(var,am_mute,by_value,$(am_volume));

EXIT=Exec(dbus-send --type=method_call --dest=org.kde.amarok / org.freedesktop.MediaPlayer.Quit)  
FADE=Exec(dbus-send --type=method_call --dest=org.kde.amarok /Player org.freedesktop.MediaPlayer.VolumeSet int32:0) 
FFWD=Macro(GETPOS);\
	Exec(dbus-send --type=method_call --dest=org.kde.amarok /Player org.freedesktop.MediaPlayer.PositionSet int32:`expr $(am_pos) + 10000`);
INF2=Send(string,INF2ACK);Send(bytes,128,0,0,0,128,0,0,0,1);\
	ExecAndSend(bytes,qdbus org.kde.amarok /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Shuffle|awk '{if($0=="true") {print "1"} else {print "0"}; }');\
	ExecAndSend(bytes,qdbus org.kde.amarok /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.LoopStatus|awk '{if($0=="None") {print "0"} else {print "1"}; }');\
	Macro(AMAROK_TITLE);\
	Send(string,$(am_title));\
	Send(bytes,0,0)

INFO=Send(string,INFOACK);\
	Send(bytes,128,0,0,0,128,0,0,0,1);\
	ExecAndSend(bytes,qdbus org.kde.amarok /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Shuffle|awk '{if($0=="true") {print "1"} else {print "0"}; }');\
	ExecAndSend(bytes,qdbus org.kde.amarok /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.LoopStatus|awk '{if($0=="None") {print "0"} else {print "1"}; }');\
	Macro(AMAROK_TITLE);\
	Send(string,$(am_title));
	
NEXT=Exec(amarok --next); 
PAUS=Exec(amarok --pause);
PLAY($$)=Macro(STRT)
STRT=Exec(amarok --play);
PREV=Exec(amarok --previous);
RWND=Macro(GETPOS);\
	Exec(dbus-send --type=method_call --dest=org.kde.amarok /Player org.freedesktop.MediaPlayer.PositionSet int32:`expr $(am_pos) - 10000`);
STOP=Exec(amarok --stop); 
VOLM($$)=Exec(dbus-send --type=method_call --dest=org.kde.amarok /Player org.freedesktop.MediaPlayer.VolumeSet int32:$(Param))

GVOL=Send(string,GVOLACK);\
	Make(var,am_volume,V=`qdbus org.kde.amarok /Player VolumeGet`;echo "$V*255/100"|bc);\
	Send(bytes,$(am_volume))

PLEN=Macro(DEFAULT_PLEN);
PLST=Macro(DEFAULT_PLST);

SHFL=\
	Make(var,shuffle_val,P=`qdbus org.kde.amarok /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Shuffle`; if [ "x$P" = "xtrue" ]; then echo 0; else echo 1; fi);\
        Exec(qdbus org.kde.amarok /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Shuffle $(shuffle_val));
REPT=\
	Make(var,repeat_val,P=`qdbus org.kde.amarok /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.LoopStatus`; if [ "x$P" = "xNone" ]; then echo 1; else echo 0; fi);\
        Exec(qdbus org.kde.amarok /Player org.freedesktop.MediaPlayer.Repeat $(repeat_val));
SHFL($$)=Exec(qdbus org.kde.amarok /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Shuffle $(Param));
REPT($$)=Exec(qdbus org.kde.amarok /Player org.freedesktop.MediaPlayer.Repeat $(Param));

%SEEK=
%SLCT($$)=

[End]
