%
% anyremote configuration file for kscd/KDE4 management. (Server-mode)
%

% STATUS nonstable
% XTEST no
% SOUND app
% TODO Play does not works properly
% ENV no
% DEF_PLAYER
% ALL_IN_ONE 

GuiAppName=Kscd
GuiAppBinary=kscd
GuiAppVersion=echo 'V=`kscd -v|grep KDE|tr -d " "|cut -f 2 -d ":"|cut -f 1 -d "."`; if [ "x$V" = "x4" ]; then echo OK; else echo NOK; fi'|sh -s
GuiAppRun=echo 'A=`qdbus|grep kscd`; if [ "x$A" = "x" ]; then echo NOK; else echo OK; fi'|sh -s
GuiAppIcon=kscd.png
GuiAppType=Application
GuiAppProtocols=Server
GuiAppDesc=KsCD is a small, fast, CDDB enabled audio CD player for UNIX platforms. This configuration file is for KsCD/KDE4.

[Protocol]=Server

(Init)=\
	Include($(CfgDir)/Utils/aliases-server.cfg);\
	Make(var,kde4_app,by_value,kscd);\
	Macro(TEST_KDE4_APP);\
	Make(var,player_name,by_value,KsCD);\
	Include($(CfgDir)/Utils/aliases-server-player.cfg);

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

[Mode]=kscd : default_player

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

SETUP_DEFAULT_PLAYER=\
	Set(layout,default);\
	Set(status,);\
	Set(title,);\
	Set(icons,$(player_name),\
		1,vol_down,\
		2,mute,\
		3,vol_up,\
		4,rewind,\
		5,play,\
		6,forward,\
		7,prev,\
		8,stop,\
		9,next,\
		*,question,\
		0,none,\
		#,no);\
	Make(var,kscd_volume,by_value,-1);

APP_MENU=\
	Set(menu,replace,Playlist,Toggle Loop,Toggle Shuffle,PowerMgmt);\
	Macro(ALLIN1MENU)

kscd_t1=\
	ExecAndSet(title,A=`qdbus|grep kscd`; if [ "x$A" != "x" ]; then qdbus org.kde.kscd /CDPlayer org.kde.KSCD.currentTrackTitle; fi)
	
Playlist=\
    Make(mode,kscd_playlist);

Toggle Loop=\
    Exec(qdbus org.kde.kscd /CDPlayer org.kde.KSCD.toggleLoop > /dev/null)

Toggle Shuffle=\
    Exec(qdbus org.kde.kscd /CDPlayer org.kde.KSCD.toggleShuffle > /dev/null)

%Eject=Exec(qdbus org.kde.kscd /CDPlayer org.kde.KSCD.eject)

% Override
0=Make(none)
1=Exec(qdbus org.kde.kscd /CDPlayer org.kde.KSCD.volumeDown > /dev/null)
2=Make(var,kscd_volume,if [ "x$(kscd_volume)" = "x-1" ]; then qdbus org.kde.kscd /CDPlayer org.kde.KSCD.getVolume; qdbus org.kde.kscd /CDPlayer org.kde.KSCD.setVolume 0 > /dev/null; else qdbus org.kde.kscd /CDPlayer org.kde.KSCD.setVolume $(kscd_volume) > /dev/null;echo "-1"; fi;);
3=Exec(qdbus org.kde.kscd /CDPlayer org.kde.KSCD.volumeUp > /dev/null)
* *=Set(text,replace,Help,1 - Vol-\n2 - Mute\n3 - Vol+\n4 - Rew\n5 - Play\n6 - FF\n7 - Prew\n8 - Stop\n9 - Next\n* * - Help\n# - Quit\n* # - Run/Quit\n If Play do not works, use FF)

PLAY=\
	Exec(qdbus org.kde.kscd /CDPlayer org.kde.KSCD.play);\
	Macro(kscd_t1);\
	Timer(kscd_t1,$(UpdateTimeout),0);

RWD=\
	Exec(POS=`qdbus org.kde.kscd /CDPlayer org.kde.KSCD.currentPosition`;NEWPOS=`expr $POS - 5`;qdbus org.kde.kscd /CDPlayer org.kde.KSCD.jumpTo $NEWPOS > /dev/null);

FF=\
	Exec(POS=`qdbus org.kde.kscd /CDPlayer org.kde.KSCD.currentPosition`;NEWPOS=`expr $POS + 5`;qdbus org.kde.kscd /CDPlayer org.kde.KSCD.jumpTo $NEWPOS > /dev/null);

PREV=\
	Exec(qdbus org.kde.kscd /CDPlayer org.kde.KSCD.previous > /dev/null);\
	Macro(kscd_t1);

NEXT=\
	Exec(qdbus org.kde.kscd /CDPlayer org.kde.KSCD.next > /dev/null);\
	Macro(kscd_t1);

STOP=\
	Exec(qdbus org.kde.kscd /CDPlayer org.kde.KSCD.stop > /dev/null);\
	Timer(kscd_t1,cancel);

RUN_IF_NEED=\
	Exec(A=`qdbus|grep kscd`; if [ "x$A" = "x" ]; then kscd --nocrashhandler; fi);

RUN_OR_QUIT=\
	Timer(kscd_t1,cancel);Exec(P=`qdbus|grep kscd`; if [ "x$P" = "x" ]; then kscd --nocrashhandler; else qdbus org.kde.kscd /CDPlayer org.kde.KSCD.quit > /dev/null; fi;)

APP_QUIT=\
	Exec(qdbus org.kde.kscd /CDPlayer org.kde.KSCD.quit > /dev/null)  

[ModeEnd]

[Mode]=kscd_playlist

(EnterMode)=Set(list,font,medium);\
	Timer(kscd_t1,cancel);\
	ExecAndSet(list,replace,Playlist,qdbus org.kde.kscd /CDPlayer org.kde.KSCD.trackList|sed 's/,/ /g;s/$/,/');\
	Set(menu,replace,Choose);
(ExitMode)=Set(list,close);\
	Macro(kscd_t1);\
	Timer(kscd_t1,$(UpdateTimeout),0);

Back($$)=Make(mode,kscd);
Choose($$)=Exec(qdbus org.kde.kscd /CDPlayer org.kde.KSCD.setTrack $(Index));
Push($$)=Macro(Choose($$));

[ModeEnd]
[End]
