%
% anyremote configuration file for amarok management. (Server-mode)
% v.2 - another layout
%
% prerequisites: ImageMagic
%

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

GuiAppName=Amarok v.2/KDE3
GuiAppBinary=amarok
GuiAppVersion=echo 'V=`amarok -v|grep KDE|tr -d " "|cut -f 2 -d ":"|cut -f 1 -d "."`; if [ "x$V" == "x3" ]; then echo OK; else echo NOK; fi'|bash -f -s
GuiAppRun=echo 'A=`dcop 2> /dev/null|grep amarok`; if [ "x$A" == "x" ]; then echo NOK; else echo OK; fi'|bash -f -s
GuiAppIcon=amarok.png
GuiAppType=Application
GuiAppProtocols=Server
GuiAppDesc=Amarok is the music player for Linux and Unix with an intuitive interface. Amarok makes playing the music you love easier than ever before - and looks good doing it. This configuration supports cover art. This configuration file is for Amarok/KDE3

[Protocol]=Server

(Init)=Include($(CfgDir)/Utils/aliases-server.cfg);\
	Exec(echo 'V=`amarok -v|grep KDE|tr -d " "|cut -f 2 -d ":"|cut -f 1 -d "."`;if [ "x$V" == "x4" ]; then $(CfgDir)/Utils/message.sh "ERROR: this configuration file is for KDE3"; fi'|bash -f -s);\
	Exec(echo 'P=`which convert|grep convert|grep -v no|wc -l|tr -d " "`;if [ "x$P" == "x1" ]; then true; else $(CfgDir)/Utils/message.sh "ERROR: ImageMagic is not installed"; fi'|bash -f -s);

(Connect)=Set(parameter,debug,on);\
	Make(mode,amarok-v2);
	
(Exit)=Macro(AMAROK_V2_EXIT);

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

AMAROK_V2_SETINFO=ExecAndSet(title,dcop amarok player title);\
	ExecAndSet(status,dcop amarok player artist);\
        ExecAndSet(cover,noname,echo 'I=`dcop amarok player coverImage`;if [ "x$I" == "x" ]; then true; else F=`basename $I`;cat $I|convert - -resize $(cover_size)x$(cover_size) -depth 8 $HOME/.anyRemote/amarok_covers/$F;echo $HOME/.anyRemote/amarok_covers/$F; fi;'|bash -f -s);
AMAROK_V2_START_TIMER=Macro(AMAROK_V2_SETINFO);\
	Timer(AMAROK_V2_SETINFO,5,0);
AMAROK_V2_STOP_TIMER =Timer(AMAROK_V2_SETINFO,cancel);
AMAROK_V2_EXIT=Exec(rm -rf $HOME/.anyRemote/amarok_covers);

[Mode]=amarok-v2

(Exit)=Macro(AMAROK_V2_EXIT);

AM_V2_LAYOUT=Set(icons,Amarok,1,prev,2,rewind,3,play,4,pause,5,stop,6,forward,7,next,8,none,9,none,*,none,0,none,#,none);\
	Set(font,small);\
        Set(layout,7x1,joystick_only,choose,3,volume,ticker,up,Vol+,down,Vol-);
AM_V2_RUN_IF=Exec(echo 'A=`dcop 2> /dev/null|grep amarok`; if [ "x$A" == "x" ]; then amarok& fi'|bash -f -s);
AM_V2_MENU=Set(menu,replace,Playlist,Vol+,Vol-,Mute,File Browser,Run Player,Quit Player,Toggle Fullscreen,Help);\
	Macro(ALLIN1MENU);\
        Macro(VOL_SET);

(EnterMode)=Macro(AM_V2_LAYOUT);\
        Macro(AM_V2_RUN_IF);\
	Make(var,am_volume,dcop amarok player getVolume);\
        Exec(rm -rf $HOME/.anyRemote/amarok_covers;mkdir $HOME/.anyRemote/amarok_covers);\
        Make(var,cover_size,by_value,64);\
        Get(cover_size);\
        Macro(AMAROK_V2_SETINFO);\
        Macro(AM_V2_MENU);

Cancel=Exec(dcop amarok MainApplication-Interface quit);
(Disconnect)=Macro(AMAROK_V2_STOP_TIMER);

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

Playlist=Macro(AMAROK_V2_STOP_TIMER);Make(mode,amarok_playlist_v2)
File Browser=Macro(AMAROK_V2_STOP_TIMER);Make(mode,amarok_file_browser_v2)

Vol+=Exec(dcop amarok player volumeUp);Macro(VOL_SET);
Vol-=Exec(dcop amarok player volumeDown);Macro(VOL_SET);

%Mute=Exec(dcop amarok player mute); -- only mutes with amarok 1.4.8

Mute=Make(var,am_volume,dcop amarok player getVolume);\
	Set(volume,0);\
        Set(menu,replace,Playlist,Vol+,Vol-,Unmute,File Browser,Run Player,Quit Player,Toggle Fullscreen,Help);\
        Macro(ALLIN1MENU);
Unmute=Make(var,am_volume,echo 'if [ "x$(am_volume)" == "x-1" ]; then dcop amarok player setVolume 0;echo "-1"; else dcop amarok player setVolume $(am_volume);echo "-1"; fi;'|bash -f -s);\
	Macro(AM_V2_MENU);
Toggle Fullscreen=Set(fullscreen,toggle);Set(cover,clear);Get(cover_size);

CoverSize($$)=Make(var,cover_size,by_value,$(Index));
Run Player=Macro(AM_V2_RUN_IF);
Quit Player=Exec(dcop amarok MainApplication-Interface quit);\
	Macro(AMAROK_V2_STOP_TIMER);\
        Set(title,);\
        Set(status,);
Help=Macro(AM_HELP);

VOL_SET=ExecAndSet(volume,dcop amarok player getVolume);

% No more 7 buttons - Nokia's Series40 has 160x120 screens 
1=Exec(dcop amarok player prev);Macro(AMAROK_V2_SETINFO);
2=Exec(dcop amarok player seekRelative -10) 
3=Exec(dcop amarok player play);Macro(AMAROK_V2_START_TIMER);Macro(VOL_SET);

4=Exec(dcop amarok player pause);Macro(AMAROK_V2_STOP_TIMER);Set(title,Paused);
5=Exec(dcop amarok player stop);Set(title,Stopped);Macro(AMAROK_V2_STOP_TIMER);
6=Exec(dcop amarok player seekRelative 10) 

7=Exec(dcop amarok player next);Macro(AMAROK_V2_SETINFO);

[ModeEnd]

[Mode]=amarok_playlist_v2
(EnterMode)=Set(list,font,medium);\
	ExecAndSet(list,replace,Playlist,dcop amarok playlist saveCurrentPlaylist;grep '<item'  $HOME/.kde/share/apps/amarok/current.xml|sed 's/<item url=\"file:\/\/\(.*\)\" \(.\)*$/\1/'|xargs -i basename {}|sed 's/uniqueid=.*//g;s/%20/ /g;s/,/\r/g;s/$/,/');\
        Set(menu,add,Choose);
(ExitMode)=Set(list,close);Set(status,Playing);Macro(AMAROK_V2_START_TIMER);

Back($$)=Make(mode,amarok-v2);
Choose($$)=Exec(dcop amarok playlist playByIndex `expr $(Index) - 1`);
[ModeEnd]

[Mode]=amarok_file_browser_v2

(EnterMode)=Set(list,font,small);Macro(FillList);Macro(UPDATEMENU);
(ExitMode)=Set(list,close);Macro(AMAROK_V2_START_TIMER);

UPDATEMENU=Set(menu,replace,GoTo,Add to playlist,Clear playlist,Go Home);

Add to playlist($$)=Exec(dcop amarok playlist addMedia `cat $HOME/.anyRemote/ar_storedir.tmp`/$(Param));
Clear playlist($$)=Exec(dcop amarok playlist clearPlaylist);
Back($$)=Make(mode,amarok-v2);

% FBROWSER v.3i 
FillList=Set(iconlist,replace,Files,folder:..);\
	Macro(FillDir);\
        Macro(FillFile);
FillDir =ExecAndSet(iconlist,add,SAME,cd "`cat $HOME/.anyRemote/ar_storedir.tmp`";ls -F --quoting-style=shell|sed 's/\*//;s/,/\r/g;s/@//;s/$/,/'|grep '/'| xargs -d '\n' -i echo "folder:" {});
FillFile=ExecAndSet(iconlist,add,SAME,cd "`cat $HOME/.anyRemote/ar_storedir.tmp`";ls -F --quoting-style=shell|sed 's/\*//;s/,/\r/g;s/@//;s/$/,/'|grep -v '/'| xargs -d '\n' -i echo "file:"{});
GoTo($$)=Make(var,goto,by_value,$(Param));\
	ExecAndSet(iconlist,replace,Files,cd "`cat $HOME/.anyRemote/ar_storedir.tmp`";echo "if [ -d $(goto) ]; then cd $(goto);fi;pwd>$HOME/.anyRemote/ar_storedir.tmp;"|bash -f -s;echo "folder:..");\
	Macro(FillDir);\
        Macro(FillFile);
Go Home($$)=ExecAndSet(iconlist,replace,Files,cd;pwd>$HOME/.anyRemote/ar_storedir.tmp;echo "folder:..");\
	Macro(FillDir);\
        Macro(FillFile);
% FBROWSER v.3i 

[ModeEnd]

[End]
