%
% anyremote configuration file for Banshee management (Server-mode)
% prerequisites: amixer/pactl utility
%

% STATUS stable
% XTEST yes
% SOUND mixer
% ENV no
% TODO FF/RWD do not works
% DEF_PLAYER   
% ALL_IN_ONE 

GuiAppName=Banshee
GuiAppBinary=echo 'B=`which banshee 2> /dev/null`;if [ "x$B" = "x" ]; then echo banshee-1; else echo banshee; fi'|sh -s
GuiAppRun=echo 'P=`ps -ef|grep banshee|grep -v grep|grep -v anyremote|grep -v edit`; if [ "x$P" = "x" ]; then echo NOK; else echo OK; fi'|sh -s
GuiAppIcon=media-player-banshee.png
GuiAppType=Application
GuiAppProtocols=Server
GuiAppDesc=Music management and playback for Gnome

[Protocol]=Server

(Init)=\
	Include($(CfgDir)/Utils/aliases-server.cfg);\
	Macro(SETUP_DEFAULT_MIXER);\
	Make(var,banshee_exec,which banshee 2> /dev/null);\
	Make(var,banshee_exec,if [ "x$(banshee_exec)" = "x" ]; then which banshee-1; else echo $(banshee_exec); fi);\
	Make(var,player_name,by_value,Banshee);\
	Include($(CfgDir)/Utils/aliases-server-player.cfg);

(Connect)=\
	Make(mode,banshee1);

[Mode]= banshee1: default_player

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

BANSHEE_DELTIMER=\
	Set(title, );\
	Set(status, );\
	Timer(BANSHEE_SETTITLE,cancel);
	
BANSHEE_SETTITLE=\
	Make(var,banshee_isrun,ps -ef|grep banshee|grep -v grep|grep -v anyremote|grep -v edit);\
	Make(var,banshee_title,if [ "x$(banshee_isrun)" != "x" ]; then $(banshee_exec) --query-title|cut -f 2 -d ":"; fi);\
	Make(var,banshee_album,if [ "x$(banshee_isrun)" != "x" ]; then $(banshee_exec) --query-album|cut -f 2 -d ":"; fi);\
	Make(var,banshee_artist,if [ "x$(banshee_isrun)" != "x" ]; then $(banshee_exec) --query-artist|cut -f 2 -d ":"; fi);\
	Set(title,$(banshee_album) - $(banshee_title));\
	Set(status,$(banshee_artist));
	
BANSHEE_CMD=\
	Exec(P=`ps -ef|grep banshee|grep -v grep|grep -v anyremote|grep -v edit`; if [ "x$P" != "x" ]; then $(banshee_cmd); fi);

BANSHEE_POS=\
	Make(var,banshee_pos,banshee --query-position|cut -f 2 -d ' '|cut -f 1 -d ',');

% Volume control and 0-9,*,# assignments by Utils/aliases-server-player.cfg

PLAY=\
	Make(var,banshee_cmd,by_value,$(banshee_exec) --toggle-playing);\
	Macro(BANSHEE_CMD);\
	Macro(BANSHEE_SETTITLE);\
	Timer(BANSHEE_SETTITLE,5,0);

RWD=\
	Macro(BANSHEE_POS);\
	Make(var,banshee_pos,echo "$(banshee_pos) - 10"|bc);\
	Make(var,banshee_cmd,by_value,$(banshee_exec) --set-position=$(banshee_pos));\
	Macro(BANSHEE_CMD);

FF=\
	Macro(BANSHEE_POS);\
	Make(var,banshee_pos,echo "$(banshee_pos) + 10"|bc);\
	Make(var,banshee_cmd,by_value,$(banshee_exec) --set-position=$(banshee_pos));\
	Macro(BANSHEE_CMD);
	
PREV=\
	Make(var,banshee_cmd,by_value,$(banshee_exec) --previous);\
	Macro(BANSHEE_CMD);\
	Macro(BANSHEE_SETTITLE);
	
STOP=\
	Make(var,banshee_cmd,by_value,$(banshee_exec) --pause);\
	Macro(BANSHEE_CMD);\
	Macro(BANSHEE_DELTIMER);
	
NEXT=\
	Make(var,banshee_cmd,by_value,$(banshee_exec) --next);\
	Macro(BANSHEE_CMD);\
	Macro(BANSHEE_SETTITLE);
	
PAUSE=\
	Make(var,banshee_cmd,by_value,$(banshee_exec) --pause);\
	Macro(BANSHEE_CMD);\
	Macro(BANSHEE_DELTIMER);

RUN_IF_NEED=\
	Exec(P=`ps -ef|grep banshee|grep -v grep|grep -v anyremote|grep -v edit`; if [ "x$P" = "x" ]; then $(banshee_exec) > /dev/null & fi);\
	Exec($(CfgDir)/Utils/run-or-switch-to.sh -switch banshee);
	
RUN_OR_QUIT=\
	Macro(BANSHEE_DELTIMER);\
	Exec(P=`ps -ef|grep banshee|grep -v grep|grep -v anyremote|grep -v edit`; if [ "x$P" = "x" ]; then $(banshee_exec) > /dev/null & else killall -r "banshee.*"; fi);
	
QUIT=\
	Macro(BANSHEE_DELTIMER);\
	Exec(killall -r "banshee.*");

[ModeEnd]

[End]
