%
% anyremote configuration file for foobnix management (Server-mode)
%

% STATUS stable
% XTEST no
% SOUND mixer
% ENV no
% DEF_PLAYER   
% ALL_IN_ONE 
% TODO http://code.google.com/p/foobnix/issues/detail?id=422

GuiAppName=foobnix
GuiAppBinary=foobnix
GuiAppRun=echo 'P=`ps -ef|grep foobnix|grep python|grep -v grep|grep -v anyremote|grep -v edit`; if [ "x$P" = "x" ]; then echo NOK; else echo OK; fi'|sh -s
GuiAppIcon=foobnix.png
GuiAppType=Application
GuiAppProtocols=Server
GuiAppDesc=

[Protocol]=Server

(Init)=\
	Include($(CfgDir)/Utils/aliases-server.cfg);\
	Macro(SETUP_DEFAULT_MIXER);\
	Macro(TEST_DBUS_SEND);\
	Make(var,player_name,by_value,Foobnix);\
	Make(var,foobnix_cmd,by_value,dbus-send --type=method_call --dest=org.mpris.MediaPlayer2.foobnix /Player);\
	Include($(CfgDir)/Utils/aliases-server-player.cfg);
	
(Connect)=Make(mode,foobnix);

[Mode]=foobnix : default_player

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

PLAY=\
	Exec($(foobnix_cmd) org.freedesktop.MediaPlayer.Play);\
	Macro(FOOBNIX_START_TIMER):

RWD=\
	Exec($(foobnix_cmd) org.freedesktop.MediaPlayer.SeekDown);

FF=\
	Exec($(foobnix_cmd) org.freedesktop.MediaPlayer.SeekUp);

PREV=\
	Exec($(foobnix_cmd) org.freedesktop.MediaPlayer.Prev);

STOP=\
	Macro(FOOBNIX_TIMER_CANCEL);\
	Exec($(foobnix_cmd) org.freedesktop.MediaPlayer.Pause);

NEXT=\
	Exec($(foobnix_cmd) org.freedesktop.MediaPlayer.Next);

PAUSE=\
	Exec($(foobnix_cmd) org.freedesktop.MediaPlayer.PlayPause);

RUN_IF_NEED=\
	Exec(P=`ps -ef|grep foobnix|grep python|grep -v grep|grep -v anyremote|grep -v edit`; \
	     if [ "x$P" = "x" ]; then foobnix & fi);\
	Exec($(CfgDir)/Utils/run-or-switch-to.sh -switch foobnix);

RUN_OR_QUIT=\
	Macro(FOOBNIX_TIMER_CANCEL);\
	Exec(P=`ps -ef|grep foobnix|grep python|grep -v grep|grep -v anyremote|grep -v edit`;\
	     if [ "x$P" = "x" ]; then foobnix & else pkill foobnix; fi);
	
APP_QUIT=\
	Macro(FOOBNIX_TIMER_CANCEL);\
	Exec(pkill foobnix)

FOOBNIX_TITLE=\
	ExecAndSet(title,foobnix --now-playing 2> /dev/null | grep -v "Other copy of player is run");

FOOBNIX_START_TIMER=\
	Macro(FOOBNIX_TITLE);\
	Timer(FOOBNIX_TITLE,$(UpdateTimeout),0);

FOOBNIX_TIMER_CANCEL=\
	Timer(FOOBNIX_TITLE,cancel);\
	Set(title,);\
	Set(status,);

[ModeEnd]

[End]
