%
% anyremote configuration file for deadbeef management. (Server-mode)
% 
% thanks s_erge http://forum.ubuntu.ru
%

% STATUS stable
% XTEST no
% ENV no
% SOUND app
% FBROWSER v.3i
% DEF_PLAYER   
% ALL_IN_ONE 

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

[Protocol]=Server

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

(Connect)=Make(mode,deadbeef);

[Mode]=deadbeef : default_player

(EnterMode)=\
	Macro(SETUP_DEFAULT_POWER_MANAGEMENT);\
	Macro(RUN_IF_NEED);\
	Macro(SETUP_DEFAULT_PLAYER_NO_FF_FWD);\
	Macro(APP_MENU);

APP_MENU=\
	Set(menu,replace,File Browser,Power Off,Suspend);\
	Macro(ALLIN1MENU);
	
% Power Off, Suspend by Utils/aliases-server-player.cfg
File Browser=\
	Timer(DEADBEEF_TITLE,cancel);\
	Make(mode,deadbeef_file_browser);

DEADBEEF_TITLE=\
	Make(var,d_song,deadbeef --nowplaying "%b - %t" 2> /dev/null);\
	Make(var,d_author,deadbeef --nowplaying "%a" 2> /dev/null);\
	Set(title,$(d_song));\
	Set(status,$(d_author));

% Possible variant
%1=Emulate(key,AudioLowerVolume)
%2=Emulate(key,AudioMute)
%3=Emulate(key,AudioRaiseVolume)
%DEADBEEF_GETVOL=Make(var,aplayer_volume,deadbeef --status|grep volume|tr -d " "|cut -f 2 -d ":");

PLAY=Exec(deadbeef --play-pause 2> /dev/null);Macro(DEADBEEF_TITLE);Timer(DEADBEEF_TITLE,5,0);
RWD=Macro(none);
FF=Macro(none)
PREV=Exec(deadbeef --prev 2> /dev/null);Macro(DEADBEEF_TITLE);
NEXT=Exec(deadbeef --next 2> /dev/null);Macro(DEADBEEF_TITLE);
PAUSE=Exec(deadbeef --toggle-pause 2> /dev/null);
STOP=Exec(deadbeef --stop 2> /dev/null);

% Override
* *=Macro(DEFAULT_HELP_NO_FF_FWD);

RUN_IF_NEED=\
	Exec(ID=`id -u`;P=`ps -fu $ID|grep deadbeef|grep -v grep|grep -v anyremote|grep -v edit`; if [ "x$P" = "x" ]; then deadbeef & fi);\
	Exec($(CfgDir)/Utils/run-or-switch-to.sh -switch deadbeef);
	
RUN_OR_QUIT=\
	Timer(DEADBEEF_TITLE,cancel);\
	Exec(ID=`id -u`;P=`pgrep -u $ID deadbeef`; if [ "x$P" = "x" ]; then  deadbeef & else deadbeef --quit 2> /dev/null; fi);\
	Set(title,);\
	Set(status,);

QUIT=\
	Exec(deadbeef --quit 2> /dev/null);\
	Timer(DEADBEEF_TITLE,cancel);\
	Set(title,);\
	Set(status,);

[ModeEnd]

[Mode]=deadbeef_file_browser

(EnterMode)=\
	Macro(FBROWSER_IC_FILL_LIST);\
	Macro(UpdateMenu);
	
GoTo($$)=\
	Macro(FBROWSER_IC_GO_TO);
	
Go Home($$)=\
	Macro(FBROWSER_IC_GO_HOME);
	
UpdateMenu=\
	Set(menu,add,GoTo,Add,Play,Go Home);

Add($$)=\
	Make(var,open_file,by_value,$(Param));\
 	Exec(deadbeef --queue `cat $HOME/.anyRemote/ar_storedir.tmp`/$(open_file));

Play($$)=\
	Make(var,open_file,by_value,$(Param));\
 	Exec(deadbeef `cat $HOME/.anyRemote/ar_storedir.tmp`/$(open_file));

Back($$)=\
        Make(mode,deadbeef);

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

[ModeEnd]

[End]
