
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Key aliases for iViewer mode
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

[Protocol]=iViewer

% SETUP_PACTL will be executed only if SETUP_AMIXER not executed
SETUP_DEFAULT_MIXER=\
	Make(var,audio_setup,P=`pacmd dump 2> /dev/null | grep set-sink-volume|wc -l`; if [ "x$P" = "x0" ]; then echo SETUP_AMIXER; else echo SETUP_PACTL; fi);\
	Macro($(audio_setup));
	
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 );

SETUP_PACTL=\
	Make(var,default_sink,LANG=C;pacmd dump|grep set-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 0 - 65535
DEFAULT_VOLUME_GET=\
	Make(var,mixer_value,$(default_mixer_get));\
	Make(var,default_mixer_value,echo "$(mixer_value)*65535/100"|bc);

DEFAULT_VOLUME_SET=\
	Make(var,mixer_value,echo "$(default_mixer_value)*100/65535"|bc);\
	Exec($(default_mixer_set) $(mixer_value));

% Password p(PASSWORD)"
p($$)=Send(string,p=ok);Send(bytes,3);

[End]
