%
% anyremote configuration file for Kaffeine management.
% prerequisites: amixer/pactl utility
% Kaffeine playlist should be already created
%

% STATUS stable
% XTEST no
% SOUND mixer
% ENV no

GuiAppName=Kaffeine
GuiAppBinary=kaffeine
GuiAppRun=echo 'A=`dcop 2> /dev/null|grep kaffeine`; if [ "x$A" == "x" ]; then echo NOK; else echo OK; fi'|bash -f -s
GuiAppIcon=kaffeine.png
GuiAppType=Application
GuiAppProtocols=AT
GuiAppDesc=KDE media player.

[Protocol]=AT

(Init)=\
	Include($(CfgDir)/Utils/aliases-at.cfg);\
	Macro(SETUP_DEFAULT_MIXER);\
	Make(var,TwoWayComm,by_value,false);\
	Macro(CHECK_RFCOMM_DEVICE);\
	Make(var,kde-version,kaffeine -v|grep KDE|tr -d " "|cut -f 2 -d ":"|cut -f 1 -d ".");

(Connect)=Make(mode,kaffeine-kde$(kde-version));

% Kaffeine/KDE D-BUS support is VERY pure
[Mode]=kaffeine-kde4

(EnterMode)=Exec(kaffeine)

QUIT=Exec(qdbus org.kde.kaffeine /MainApplication org.kde.KApplication.quit;killall kaffeine)

1=Emulate(key,KP_Subtract);
2=Emulate(key,m);
3=Emulate(key,KP_Add);

4=Emulate(key,Left)
5=Emulate(key,space);
6=Emulate(key,Right)

7=Emulate(key,Page_Up)
8=Emulate(key,BackSpace);
9=Emulate(key,Page_Down)

* *=Exec(F="$HOME/.anyRemote/anyrem.hlp";echo "1 - Vol-  2 - Mute       3 - Vol+" > $F;echo "4 - Rew   5 - Play/Pause 6 - FF" >> $F;echo "7 - Prew  8 - Stop       9 - Next" >> $F;echo "*         0 - Fullscreen # - Quit" >> $F);\
	Macro(SHOW_HELP);
* #=Exec(echo 'P=`pgrep kaffeine`; if [ "x$P" == "x" ]; then kaffeine; else qdbus org.kde.kaffeine /MainApplication org.kde.KApplication.quit;killall kaffeine; fi;' |bash -f -s)
0=Emulate(key,f);
#=Macro(QUIT);

[ModeEnd]

[Mode]=kaffeine-kde3

(EnterMode)=Exec(kaffeine)
(Disconnect)=Exec(dcop kaffeine KaffeineIface pause);Exec(kdialog --msgbox "Disconnected... Set to pause")

(InCall)=Exec(dcop kaffeine KaffeineIface pause);Make(remote,off)
(EndCall)=Make(remote,on);Exec(dcop kaffeine KaffeineIface pause)

Answer=Make(disconnect);
Cancel=Exec(dcop kaffeine KaffeineIface quit);Exit

1=Macro(DEFAULT_VOLUME_DOWN)
2=Macro(DEFAULT_TOGGLE_MUTE)
3=Macro(DEFAULT_VOLUME_UP)

4=Exec(dcop kaffeine KaffeineIface posMinus)
5=Exec(dcop kaffeine KaffeineIface play;dcop kaffeine KaffeineIface fullscreen)
6=Exec(dcop kaffeine KaffeineIface posPlus)

7=Exec(dcop kaffeine KaffeineIface previous)
8=Exec(dcop kaffeine KaffeineIface stop;dcop kaffeine KaffeineIface fullscreen)
9=Exec(dcop kaffeine KaffeineIface next)

* *=Exec(F="$HOME/.anyRemote/anyrem.hlp";echo "1 - Vol-  2 - Mute   3 - Vol+" > $F;echo "4 - Rew   5 - Play   6 - FF" >> $F;echo "7 - Prew  8 - Stop   9 - Next" >> $F;echo "*         0 - Pause  # - Quit" >> $F);\
	Macro(SHOW_HELP);
* #=Exec(echo 'P=`dcop|grep kaffeine`; if [ "x$P" == "x" ]; then kaffeine;sleep 2;dcop kaffeine KaffeineIface setNumber 1; else dcop kaffeine KaffeineIface quit; fi;' |bash -f -s)
0=Exec(dcop kaffeine KaffeineIface pause)
#=Exec(dcop kaffeine KaffeineIface quit)  
[ModeEnd]
[End]
