%
% anyremote configuration file for sound management. (Server-mode)
% prerequisites: amixer utility
%

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

GuiAppName=Sound volume test
GuiAppIcon=sound.png
GuiAppType=Example
GuiAppBinary=true
GuiAppProtocols=Server
GuiAppDesc=Control sound volume with amixer utility

% 1 - increase sound volume
% 2 - mute/unmute
% 3 - increase sound volume
% 5 -  show list of available controls

[Protocol]=Server

(Init)=\
	Include($(CfgDir)/Utils/aliases-server.cfg);\
	Macro(INIT_CONTROL);\
	Macro(TEST_MIXER);

(Connect)=\
	Set(parameter,debug,on);\
	Set(icons,SoundControl,1,minus,2,mute,3,plus,4,default,5,file,6,default,7,default,8,default,9,default,0,default,*,question,#,default);\
	Macro(SET_VIEW);

TEST_MIXER=\
	Exec(TEST=`amixer  -c $(MixerCard) sget Master,0`;U=`echo $TEST|grep "Usage: amixer" |wc -l`;if [ "x$U" != "x0" ]; then $(CfgDir)/Utils/message.sh "ERROR: You have to correct example according to Your system configuration !"; fi);

INIT_CONTROL=\
	Exec(if [ -f $(TmpDir)/amixer.control ]; then true; else echo "Master@0" > $(TmpDir)/amixer.control; fi)

SET_VIEW=\
	Set(menu,replace,Controls);\
	ExecAndSet(title,cat $(TmpDir)/amixer.control|sed "s/@/,/");

Cancel=\
    Make(exit);

Controls=\
	ExecAndSet(list,replace,Mixer Controls,amixer scontrols|sed 's/Simple mixer control //;s/,/@/;s/$/,/');\
	Set(menu,replace,Choose);

	
Choose($$)=\
	Exec(echo $(Param) > $(TmpDir)/amixer.control);\
	Set(list,close);\
	Macro(SET_VIEW);
	
Push($$)=Macro(Choose($$));

Back=Set(text,close);Macro(SET_VIEW);
Back($$)=Set(list,close);Macro(SET_VIEW);

1=Exec(amixer -c $(MixerCard) sset `cat $(TmpDir)/amixer.control|sed "s/@/,/"` 5%-    -q)
2=Exec(amixer -c $(MixerCard) sset `cat $(TmpDir)/amixer.control|sed "s/@/,/"` toggle -q)
3=Exec(amixer -c $(MixerCard) sset `cat $(TmpDir)/amixer.control|sed "s/@/,/"` 5%+    -q)

5=Macro(Controls);

* *=Set(text,replace,Help,1 - Vol-\n2 - Mute/Unmute\n3 - Vol+\n5 - Choose mixer control\nKnown problem: mute/unmute can work incorrectly with PulseAudio)

[End]

