%
% anyremote configuration file for moc (http://moc.daper.net) management. (Server-mode)
% prerequisites: amixer/pactl utility, it needs to create MOC playlist before
%

% STATUS nonstable
% TODO work with playlists
% XTEST no
% SOUND mixer
% ENV no
% FBROWSER v.3
% DEF_PLAYER   
% ALL_IN_ONE 

GuiAppName=MOC
GuiAppBinary=mocp
GuiAppRun=echo 'P=`ps -ef|grep mocp|grep -v grep|grep -v anyremote|grep -v nedit`; if [ "x$P" == "x" ]; then echo NOK; else echo OK; fi'|bash -f -s
GuiAppType=Application
GuiAppProtocols=Server
GuiAppDesc=Console audio player for Linux/UNIX

[Protocol]=Server

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

(Connect)=Make(mode,moc);

MOC_TITLE=ExecAndSet(title,A=`mocp -i|grep Artist|sed "s/Artist: //"`;T=`mocp -i|grep SongTitle|sed "s/SongTitle: //"`;echo "$A $T");
MOC_TIMER=Timer(MOC_TITLE,5,0);

(Disconnect)=Timer(MOC_TITLE,cancel);

[Mode]=moc : default_player

APP_MENU=\
	Set(menu,replace,File Browser,Power Off,Suspend);\
	Macro(ALLIN1MENU);

% Power Off, Suspend by Utils/aliases-server-player.cfg
File Browser=\
	Make(mode,moc_file_browser)

PLAY=Exec(mocp -p);\
	Macro(MOC_TITLE);\
	Macro(MOC_TIMER);
RWD=Exec(mocp -k -10) 
FF=Exec(mocp -k 10) 
PREV=Exec(mocp -r);Macro(MOC_TITLE);
NEXT=Exec(mocp -f);Macro(MOC_TITLE);
STOP=Exec(mocp -s);Timer(MOC_TITLE,cancel);
PAUSE=Exec(mocp -G);

RUN_IF_NEED=\
	Exec(ID=`id -u`;P=`ps -fu $ID|grep mocp|grep -v grep|grep -v anyremote|grep -v edit`; if [ "x$P" = "x" ]; then mocp -S& fi);
RUN_OR_QUIT=\
	Exec(ID=`id -u`;P=`ps -fu $ID|grep mocp|grep -v grep|grep -v anyremote|grep -v edit`; if [ "x$P" = "x" ]; then mocp -S& else mocp -x; fi);
QUIT=Exec(mocp -x);\
	Timer(MOC_TITLE,cancel);\
	Set(title,);\
	Set(status,);

[ModeEnd]

[Mode]=moc_file_browser

(EnterMode)=\
	Timer(MOC_TITLE,cancel);\
	Set(list,font,small);\
	Macro(FBROWSER_FILL_LIST);\
	Macro(UPDATEMENU);
	
(ExitMode)=\
	Set(list,close);\
	Macro(MOC_TITLE);\
	Macro(MOC_TIMER);

UPDATEMENU=Set(menu,replace,Go To,Go Home,Play it,Enqueue);

Go To($$)  =Macro(FBROWSER_GO_TO);
Go Home($$)=Macro(FBROWSER_GO_HOME);
Back($$)=Make(mode,moc);
Play it($$)=Exec(mocp -l "`cat $HOME/.anyRemote/ar_storedir.tmp`/$(Param)");
Enqueue($$)=Exec(mocp -q "`cat $HOME/.anyRemote/ar_storedir.tmp`/$(Param)");

%Push($$) use from aliases-server-fbrowser-v3.cfg

[ModeEnd]

[End]
