%
% anyremote configuration file for mplayer management. (Server-mode)
% 
% Thanks Kristjan Ugrin for corrections.
%
% TODO: support DBUS 
%       http://code.google.com/p/clementine-player/wiki/MPRIS
%

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

GuiAppName=Clementine
GuiAppBinary=clementine
GuiAppRun=echo 'A=`ps -ef|grep clementine|grep -v grep|grep -v edit`; if [ "x$A" = "x" ]; then echo NOK; else echo OK; fi'|sh -s
GuiAppIcon=clementine.png
GuiAppType=Application
GuiAppProtocols=Server
GuiAppDesc=A music player.

[Protocol]=Server

(Init)=\
	Include($(CfgDir)/Utils/aliases-server.cfg);\
	Macro(SETUP_DEFAULT_MIXER);\
	Make(var,player_name,by_value,Clementine);\
	Include($(CfgDir)/Utils/aliases-server-player.cfg);

(Connect)=Make(mode,clementine);

[Mode]=clementine : default_player

% (EnterMode) by Utils/aliases-server-player.cfg

APP_MENU=\
	Set(menu,replace,Playlist,Shuffle,Repeat,Power Off,Suspend);\
	Macro(ALLIN1MENU);

% Power Off, Suspend by Utils/aliases-server-player.cfg
	
Shuffle=\
	Exec(P=`qdbus org.mpris.clementine /org/mpris/MediaPlayer2 Shuffle`; \
		if [ "x$P" = "xtrue" ]; \
		then \
		    qdbus org.mpris.clementine /org/mpris/MediaPlayer2 Shuffle false & \
		else \
		    qdbus org.mpris.clementine /org/mpris/MediaPlayer2 Shuffle true & \
		fi);

Repeat=\
	Exec(P=`qdbus org.mpris.clementine /org/mpris/MediaPlayer2 LoopStatus`; \
		if [ "x$P" = "xNone" ]; \
		then \
		    qdbus org.mpris.clementine /org/mpris/MediaPlayer2 LoopStatus Track & \
		else \
		    qdbus org.mpris.clementine /org/mpris/MediaPlayer2 LoopStatus None & \
		fi);

Playlist=\
	ExecAndSet(list,replace,Playlist,$(CfgDir)/Utils/getPlayList.sh org.mpris.clementine);\
  	ExecAndSet(list,select,expr 1 + `qdbus org.mpris.clementine  /TrackList GetCurrentTrack`);\
	Set(menu,replace,Choose);
	
Push($$)=\
	Macro(Choose($$))
	
Choose($$)=\
	Exec(qdbus org.mpris.clementine /TrackList PlayTrack `expr $(Index) - 1`);

% Volume control and 0-9,*,# assignments by Utils/aliases-server-player.cfg
%1=Exec(clementine --volume-down)
%2=Macro(DEFAULT_TOGGLE_MUTE)
%3=Exec(clementine --volume-up)

PLAY =Exec(clementine -t);
RWD  =Exec(clementine --seek-by -10);
FF   =Exec(clementine --seek-by +10);
PREV =Exec(clementine -r);
STOP =Exec(clementine -s);
NEXT =Exec(clementine -f);
PAUSE=Exec(clementine -u);

RUN_IF_NEED=\
	Exec($(CfgDir)/Utils/run-or-switch-to.sh clementine);
	
RUN_OR_QUIT=\
	Exec(P=`ps auxc|grep clementine`; if [ "x$P" = "x" ]; then clementine & else killall clementine; fi);
	
QUIT=Exec(killall clementine)

[ModeEnd]


[End]
