%
% anyremote configuration file for Banshee management. (Server-mode)
% v.2 - another layout
%
% prerequisites: amixer/pactl utility, ImageMagic
%

% STATUS nonstable, banshee drop support of --query-cover-uri option https://bugzilla.gnome.org/show_bug.cgi?id=673815
% XTEST no
% SOUND mixer
% ENV no
% ALL_IN_ONE 

GuiAppName=Banshee-v2
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
GuiAppProtocols=Server
GuiAppType=Example
GuiAppDesc=Music management and playback for Gnome. Different layout and cover art support.

[Protocol]=Server

(Init)=\
	Include($(CfgDir)/Utils/aliases-server.cfg);\
	Macro(SETUP_DEFAULT_MIXER);\
	Macro(TEST_IMAGEMAGIC);\
	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,banshee_cover_art_support,CA=`$(banshee_exec) --help-all|grep query-cover-uri`; if [ "x$CA" = "x" ]; then echo 1; else echo 0; fi);

(Connect)=Make(mode,banshee-v2);

BANSHEE_V2_SONG_INFO=\
	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));\
	Macro(BANSHEE_COVER,by_value,$(banshee_cover_art_support));

BANSHEE_COVER=\	
	ExecAndSet(cover,noname,I=`$(banshee_exec) --query-cover-uri|sed "s/CoverUri: //"`;if [ "x$I" != "x" ]; then F=`basename $I`;cat $I|convert - -resize $(cover_size)x$(cover_size) -depth 8 $(TmpDir)/banshee_covers/$F;echo $(TmpDir)/banshee_covers/$F; fi);

BANSHEE_V2_START_TIMER=\
	Timer(BANSHEE_V2_SONG_INFO,5,0);

BANSHEE_V2_STOP_TIMER=\
	Timer(BANSHEE_V2_SONG_INFO,cancel);
	
BANSHEE_V2_EXIT=\
	Exec(rm -rf $(TmpDir)/banshee_covers);


[Mode]=banshee-v2

(Exit)=Macro(BANSHEE_V2_EXIT);

QUIT=Exec(killall -r "banshee.*");

BANSHEE_V2_LAYOUT=\
	Set(icons,Banshee,1,prev,2,rewind,3,play,4,pause,5,stop,6,forward,7,next,8,none,9,none,*,none,0,none,#,none);\
	Set(layout,7x1,joystick_only,choose,3,volume,ticker,up,Vol+,down,Vol-);\
	Set(font,small);

BANSHEE_RUN_IF=\
	Exec(P=`ps -ef|grep banshee|grep -v grep|grep -v anyremote|grep -v edit`; if [ "x$P" = "x" ]; then $(banshee_exec)& fi);\
	Exec($(CfgDir)/Utils/run-or-switch-to.sh -switch banshee);
	
BANSHEE_V2_MENU=\
	Set(menu,replace,Vol+,Vol-,Mute,Run Player,Quit Player,Toggle Fullscreen,Help);\
	Macro(ALLIN1MENU);

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 ',');

(EnterMode)=\
	Macro(BANSHEE_RUN_IF);\
	Macro(BANSHEE_V2_LAYOUT);\
	Macro(VOL_SET);\
	Macro(BANSHEE_V2_MENU);\
	Exec(rm -rf $(TmpDir)/banshee_covers;mkdir $(TmpDir)/banshee_covers);\
	Make(var,cover_size,echo 64);\
	Get(cover_size);
	
Cancel=Macro(QUIT);

(Disconnect)=Macro(BANSHEE_V2_STOP_TIMER);

Back=Set(text,close);Macro(BANSHEE_V2_MENU);

VOL_SET=\
	Macro(DEFAULT_VOLUME_GET);\
	Set(volume,$(default_mixer_value));

Vol+=Macro(DEFAULT_VOLUME_UP);\
	Macro(VOL_SET);
	
Vol-=Macro(DEFAULT_VOLUME_DOWN);\
	Macro(VOL_SET);

% Android support
VOL-=Macro(Vol-);
VOL+=Macro(Vol+);

Mute=Macro(DEFAULT_TOGGLE_MUTE);\
	Set(volume,0);\
	Set(menu,replace,Vol+,Vol-,Unmute,Run Player,Quit Player,Toggle Fullscreen,Help);\
	Macro(ALLIN1MENU);
	
Unmute=\
	Macro(DEFAULT_TOGGLE_MUTE);\
	Macro(BANSHEE_V2_MENU);
	
Toggle Fullscreen=\
	Set(fullscreen,toggle);\
	Set(cover,clear);\
	Get(cover_size);

CoverSize($$)=Make(var,cover_size,echo $(Index));

Run Player=Macro(BANSHEE_RUN_IF);

Quit Player=\
	Macro(BANSHEE_V2_STOP_TIMER);\
	Macro(QUIT);\
	Set(title,);\
	Set(status,);

Help=Set(text,replace,Help,Manage player by joystick or from menu);


% No more 7 buttons - Nokias Series40 has 160x120 screens 
1=Make(var,banshee_cmd,by_value,$(banshee_exec) --previous);\
	Macro(BANSHEE_CMD);\
	Macro(BANSHEE_V2_SONG_INFO);
	
2=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);

3=Make(var,banshee_cmd,by_value,$(banshee_exec) --toggle-playing);\
	Macro(BANSHEE_CMD);\
	Macro(BANSHEE_V2_SONG_INFO);\
	Macro(BANSHEE_V2_START_TIMER);

4=Make(var,banshee_cmd,by_value,$(banshee_exec) --pause);\
	Macro(BANSHEE_CMD);\
	Macro(BANSHEE_V2_STOP_TIMER);\
	Set(title,);\
	Set(status,);

5=Make(var,banshee_cmd,by_value,$(banshee_exec) --pause);\
	Macro(BANSHEE_CMD);\
	Macro(BANSHEE_V2_STOP_TIMER);
	
6=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);
	
7=Make(var,banshee_cmd,by_value,$(banshee_exec) --next);\
	Macro(BANSHEE_CMD);\
	Macro(BANSHEE_V2_SONG_INFO);

[ModeEnd]

[End]
