
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Key aliases for Bemused emulation mode
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

[Protocol]=Bemused

% Use Bemused quirks
BEMUSED_SETUP=\
	Make(var,Bemused,by_value,true);
	
STRT=Macro(PLAY)
LADD=Macro(PLAY)
STEN=Macro(STOP)

SETUP_DEFAULT_MIXER=\
	Macro(SETUP_AMIXER,pactl -h|grep set-sink-mute|wc -l);\
	Macro(SETUP_PACTL);
% SETUP_PACTL will be executed only if SETUP_AMIXER not executed
	
SETUP_AMIXER=\
	Make(var,default_mixer_up,by_value,amixer sset Master,0 5%+ -q);\
	Make(var,default_mixer_down,by_value,amixer sset Master,0 5%- -q);\
	Make(var,default_mixer_mute,by_value,amixer sset Master,0 toggle -q);\
	Make(var,default_mixer_get,by_value,amixer sget Master,0|grep '\['|head -1|cut -f 2 -d "["|cut -f 1 -d "]"|sed "s/%//");\
	Make(var,default_mixer_set,by_value,amixer -q sset Master,0 );\
	Make(stop);

SETUP_PACTL=\
	Make(var,default_sink,LANG=C;pactl stat|grep "Default Sink"|cut -f 2 -d ":"|tr -d ' ');\
	Make(var,default_mixer_down,by_value,$(CfgDir)/Utils/pulse-audio-ctl.sh down $(default_sink));\
	Make(var,default_mixer_up,by_value,$(CfgDir)/Utils/pulse-audio-ctl.sh up $(default_sink));\
	Make(var,default_mixer_mute,by_value,$(CfgDir)/Utils/pulse-audio-ctl.sh mute $(default_sink));\
	Make(var,default_mixer_get,by_value,$(CfgDir)/Utils/pulse-audio-ctl.sh get $(default_sink));\
	Make(var,default_mixer_set,by_value,$(CfgDir)/Utils/pulse-audio-ctl.sh set $(default_sink) );

DEFAULT_VOLUME_UP  =Exec($(default_mixer_up));
DEFAULT_VOLUME_DOWN=Exec($(default_mixer_down));
DEFAULT_TOGGLE_MUTE=Exec($(default_mixer_mute));

% default_mixer_value in range 1-100
DEFAULT_VOLUME_GET=Make(var,default_mixer_value,$(default_mixer_get));
DEFAULT_VOLUME_SET=Exec($(default_mixer_set) $(default_mixer_value));

DEFAULT_GVOL=\
	Macro(DEFAULT_VOLUME_GET);\
	Make(var,tt_volume,echo "$(default_mixer_value)*255/100"|bc);\
	Send(string,GVOLACK);\
	Send(bytes,$(tt_volume))

DEFAULT_FADE=\
	Make(var,default_mixer_value,by_value,0);\
	Macro(DEFAULT_VOLUME_SET)

% The following is a trick. Replays are not real, just to satisfy client.
DEFAULT_PLEN=\
	Send(bytes,0,100);

DEFAULT_PLST=\
	Send(string,PLSTACK);\
	Send(bytes,0,1,35,10);\
	Send(string,NoName);\
	Send(bytes,10,0)
	
CHCK=Send(string,Y);
DINF=Send(string,DINFACK);Send(bytes,0,0,0,244,0,0,32,0,0,0,0,2);
DLST=Send(bytes,255,0,0)
DOWN=Send(bytes,0,100);Send(string,NoName)
FINF=Send(string,FINFACK);Send(bytes,0,0,0,100);
LIST=Send(bytes,255,0,0)
VERS=Send(string,VERSACK);Send(bytes,1,73);



[End]
