%
% anyremote configuration file for XMMS2 management v3 (Server-mode)
%
% prerequisites: xmms2-client-cli package, python-xmmsclient
%
% Thanks to Gyuris Szabolcs for this configuration file
%

% STATUS unknown
% XTEST no
% SOUND app
% ENV no
% ALL_IN_ONE 

GuiAppName=XMMS2
GuiAppBinary=xmms2
GuiAppRun=echo 'P=`ps -ef|grep xmms2d|grep -v grep|grep -v anyremote|grep -v nedit`; if [ "x$P" == "x" ]; then echo NOK; else echo OK; fi'|bash -f -s
GuiAppIcon=xmms.png
GuiAppType=Application
GuiAppProtocols=Server
GuiAppDesc=XMMS2 is definitely an audio player. But it is  not a general multimedia player - it will not play videos. It has a modular framework and plugin architecture for audio processing, visualisation and output, but this framework has not been designed to support video.

[Protocol]=Server

(Init)=Include($(CfgDir)/Utils/aliases-server.cfg);
(Connect)=Set(parameter,debug,off);\
	Make(mode,xmms2);

Cancel=Exit

xmms_t1=ExecAndSet(title,xmms2 current);

[Mode]=xmms2

(EnterMode)=Make(var,x2_volume,by_value,-1);\
	Exec(echo "if ps -ef|grep -v grep|grep -v anyremote|grep xmms2d >/dev/null; then true;else xmms2-launcher; sleep 1; fi"|bash -f -s);\
	Macro(PLAYERLAYOUT);\
	Set(font,small);\
	Set(menu,replace,Playlist,Toggle Shuffle,Audio Device,XMMS2 cmd);\
	Macro(ALLIN1MENU)
(ExitMode)=Timer(xmms_t1,cancel)

Cancel=Exit
Back=Set(text,close);Set(menu,replace,Playlist,Toggle Shuffle;Audio Device,XMMS2 cmd);Macro(ALLIN1MENU)

% PlayerLayout to set the main screen
PLAYERLAYOUT=\
	Set(title,-);\
	Set(layout,default);\
	Set(icons,Xmms2,1,vol_down,2,mute,3,vol_up,4,rewind,5,play,6,forward,7,prev,8,stop,9,next,*,question,0,pause,#,no);\
	Macro(ALLIN1MENU);\
	ExecAndSet(status,echo "if $(CfgDir)/Utils/xmms_is_playing; then echo \"Playing\"; else echo \"Stopped\"; fi"|bash -f -s);\
	ExecAndSet(title,xmms2 current)

% Menu items
Toggle Shuffle=Exec(xmms2 shuffle);
% there isn't any repeat in xmms2 cli now % Toggle Repeat=Exec(xmms2 repeat);
Playlist=Make(mode,xmms_playlist)
Audio Device=Make(mode,xmms_ad)
XMMS2 cmd=Set(editfield,XMMS2 Cli,Param,add);Make(mode,clicmd)
PlayIfPlaying=ExecAndSet(status,echo "if $(CfgDir)/Utils/xmms_is_playing ; then xmms2 play; echo \"Playing\"; else echo \"Stopped\"; fi"|bash -f -s)

1=Exec(xmms2 volume -5)
2=Make(var,x2_volume,echo 'if [ "x$(x2_volume)" == "x-1" ]; then xmms2 volume_list|tail -1|tr -d " "|cut -f 2 -d "=";xmms2 volume 0; else xmms2 volume $(x2_volume); echo "-1"; fi;'|bash -f -s)
3=Exec(xmms2 volume +5)

4=Exec(xmms2 seek -10)
5=ExecAndSet(status,xmms2 play;echo Playing);Macro(xmms_t1);Timer(xmms_t1,5,0)
6=Exec(xmms2 seek +10)

7=ExecAndSet(title,xmms2 prev;sleep 1;xmms2 current)
8=Exec(xmms2 stop);Set(status,Stopped);Timer(xmms_t1,cancel);
9=ExecAndSet(title,xmms2 next;sleep 1;xmms2 current)

* *=Set(text,replace,Help,1 Vol-\n2 Mute\n3 Vol+\n4 Rew\n5 Play\n6 FF\n7 Prew\n8 Stop\n9 Next\n* Help\n0 Pause\n# Exit);
* #=Exec(echo "if ps -ef|grep -v grep|grep -v anyremote|grep xmms2d >/dev/null; then xmms2 quit;else xmms2-launcher;fi"|bash -f -s);
0=Exec(xmms2 toggleplay);Macro(PlayIfPlaying)
#=Exec(xmms2 quit);Exit

[ModeEnd]

% PlayList mode
[Mode]=xmms_playlist
(EnterMode)=Set(list,font,small);\
	Timer(xmms_t1,cancel);\
	ExecAndSet(list,replace,Playlist,l=$(xmms2 list| grep "\["|tr -d ','|sed 's/$/,/'); echo "if [ -z \"$l\" ]; then echo \"<empty>\"; else echo \"$l\"; fi"|bash -f -s);\
	ExecAndSet(list,select,l=$(xmms2 list|grep -n '[>]'|cut -d: -f1); echo "if [ -z \"$l\" ]; then echo \"1\"; else echo \"$l\"; fi"|bash -f -s);\
	Set(menu,replace,Choose);
(ExitMode)=Set(list,close);Macro(xmms_t1);Timer(xmms_t1,5,0)

Back($$)=Make(mode,xmms2)
Choose($$)=Make(var,x2_idx,echo "$(Index)-1"|bc);Exec(xmms2 jump $(x2_idx));\
	Macro(PlayIfPlaying)
Push($$)=Macro(Choose($$));

[ModeEnd]

% Choose Audio Device
[Mode]=xmms_ad
% Alsa devices: default, bluetooth
%% asoundrc:
%% pcm.bluetooth {
%%   type bluetooth
%%   device <MAC>
%%   profile "auto"
%% }
(EnterMode)=Set(list,font,small);\
	Timer(xmms_t1,cancel);\
	Set(list,replace,Audio Devices,default,bluetooth);\
	Set(menu,replace,Choose);
(ExitMode)=Set(list,close);\
	Macro(xmms_t1);\
	Timer(xmms_t1,5,0)
Back($$)=Make(mode,xmms2);
Choose($$)=Exec(echo "if $(CfgDir)/Utils/xmms_is_playing; then xmms2 stop;xmms2 config alsa.device $(Param); sleep 1; xmms2 play; sleep 1; else xmms2 config alsa.device $(Param); fi"|bash -f -s);\
	Macro(PlayIfPlaying);\
	Make(mode,xmms2)
[ModeEnd]

[Mode]=clicmd
Ok($$)=Set(text,close);\
	ExecAndSet(text,replace,XMMS2 Cli,echo "xmms2 $(Param);echo -e \"---\\nExit code:<$?>\""|/bin/bash -s -f)
Back($$)=Make(mode,xmms2)
Back=Make(mode,xmms2)
[ModeEnd]

[End]
