%
% anyremote configuration file for XMMS management (Server-mode)
% prerequisites: xmmsctrl package
%

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

GuiAppName=XMMS
GuiAppBinary=xmms
GuiAppRun=echo 'P=`ps -ef|grep xmms|grep -v xmms2|grep -v grep|grep -v anyremote|grep -v edit`; if [ "x$P" == "x" ]; then echo NOK; else echo OK; fi' | bash -f -s
GuiAppIcon=xmms.png
GuiAppType=Application
GuiAppProtocols=Server
GuiAppDesc=XMMS is a multimedia player for unix systems. XMMS stands for X MultiMedia System and can play media files such as MP3, MOD's, WAV and others with the use of Input plugins.

[Protocol]=Server

(Init)=Include($(CfgDir)/Utils/aliases-server.cfg);\
	Exec(echo 'P=`which xmmsctrl|grep xmmsctrl|grep -v no|wc -l|tr -d " "`;if [ "x$P" == "x1" ]; then true; else $(CfgDir)/Utils/message.sh "ERROR: xmmsctrl package is not installed"; fi'|bash -f -s);\
	Make(var,player_name,by_value,XMMS);\
	Include($(CfgDir)/Utils/aliases-server-player.cfg);

(Connect)=Make(mode,xmms);

xmms_t1=ExecAndSet(title,basename "`xmmsctrl cur`"|sed 's/%20/ /g')

[Mode]=xmms : default_player

(EnterMode)=\
	Make(var,xmms_volume,by_value,-1);\
	Macro(RUN_IF_NEED);\
	Macro(SETUP_DEFAULT_PLAYER);\
	Macro(APP_MENU);
	
(ExitMode)=Timer(xmms_t1,cancel)

APP_MENU=\
	Set(menu,replace,Playlist,Toggle Shuffle,Toggle Repeat);\
	Macro(ALLIN1MENU);

Toggle Shuffle=Exec(xmmsctrl shuffle);
Toggle Repeat=Exec(xmmsctrl repeat);
Playlist=Make(mode,xmms_playlist)

% use custom volume controls
1=Exec(xmmsctrl vol -5)
2=Make(var,xmms_volume,echo 'if [ "x$(xmms_volume)" == "x-1" ]; then xmmsctrl print %v; xmmsctrl vol 0; else xmmsctrl vol $(xmms_volume); echo "-1"; fi;'|bash -f -s)
3=Exec(xmmsctrl vol +5)

% Android support
VOL-=Exec(xmmsctrl vol -5)
VOL+=Exec(xmmsctrl vol +5)

PLAY =ExecAndSet(status,sh -c "if xmmsctrl playing;then xmmsctrl stop;echo Stopped; else xmmsctrl play;echo Playing; fi");\
	Macro(xmms_t1);\
	Timer(xmms_t1,5,0);
RWD  =Exec(xmmsctrl time -10);
FF   =Exec(xmmsctrl time +10);
PREV =ExecAndSet(title,xmmsctrl prev;basename "`xmmsctrl cur`"|sed 's/%20/ /g');
STOP =Exec(xmmsctrl stop);Set(status,Stopped);Timer(xmms_t1,cancel);
NEXT =ExecAndSet(title,xmmsctrl next;basename "`xmmsctrl cur`"|sed 's/%20/ /g');
PAUSE=Exec(xmmsctrl pause);ExecAndSet(status,sh -c "sleep 1;if xmmsctrl paused; then echo Paused; else echo Playing; fi");

RUN_IF_NEED=Exec(sh -c "if xmmsctrl running;then true;else xmmsctrl launch; fi");
RUN_OR_QUIT=Exec(sh -c "if xmmsctrl running;then xmmsctrl quit;else xmmsctrl launch; fi");
APP_QUIT=Exec(xmmsctrl quit)

[ModeEnd]

[Mode]=xmms_playlist
(EnterMode)=\
	Timer(xmms_t1,cancel);\
	Set(list,font,medium);\
	ExecAndSet(list,replace,Playlist,xmmsctrl playlist|tr -d ','|tr -s ' '|cut -f2,3,4,5,6,7|sed 's/%20/ /g;s/$/,/;s/(/-/g;s/)/-/g');\
	Set(menu,replace,Choose);
	
(ExitMode)=\
	Set(list,close);\
	Macro(xmms_t1);\
	Timer(xmms_t1,5,0)

Back($$)=Make(mode,xmms);
Choose($$)=Exec(xmmsctrl track $(Index));
Push($$)=Macro(Choose($$));

[ModeEnd]
[End]
