
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Key aliases for AT mode
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

[Protocol]=AT

% not the only variant - also possible to use stdin, ilirc, IR or cable connection
%CHECK_RFCOMM_DEVICE=Exec(DD=`echo $(Device)|cut -f 1 -d ':'`;\
%                        if [ "x$DD" != "xrfcomm" ]; then \
%			     $(CfgDir)/Utils/message.sh "ERROR: It needs to set Device parameter properly to /dev/rfcomm* !"; \
			 fi);

% Motorola - Red and Green buttons
S=Macro(Answer);
E=Macro(Cancel);

% SE's - SwitchOff and C buttons
c=Macro(Answer);
L=Macro(Cancel);
p=Macro(Cancel);

% Sagem - Red and Green buttons
83=Macro(Answer);
69=Macro(Cancel);

% Sockets & Sagem
42=Macro(*)
35=Macro(#)
48=Macro(0)
49=Macro(1)
50=Macro(2)
51=Macro(3)
52=Macro(4)
53=Macro(5)
54=Macro(6)
55=Macro(7)
56=Macro(8)
57=Macro(9)

% Vol+/- for Motorola
U=Macro(3)
D=Macro(1)

% Aliases for AverMedia IR remote
KEY_VOLUMEDOWN=Macro(1)
KEY_MIN_INTERESTING=Macro(2)
KEY_VOLUMEUP=Macro(3)

KEY_CHANNELUP=Macro(9)
KEY_CHANNELDOWN=Macro(7)
KEY_ZOOM=Macro(5)

KEY_RED=Macro(4)
KEY_PLAY=Macro(5)
KEY_YELLOW=Macro(6)

KEY_GREEN=Macro(7)
KEY_STOP=Macro(8)
KEY_BLUE=Macro(9)

KEY_TEXT=Macro(*)
KEY_PAUSE=Macro(0)
KEY_POWER=Macro(#)

SHOW_HELP=\
    Exec(notify-send -t 5000 "`cat $(TmpDir)/anyrem.hlp`");

SHOW_MSG=\
    Exec(notify-send -t 100 "$(message)");

% 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 1-100
DEFAULT_VOLUME_GET=\
    Make(var,default_mixer_value,$(default_mixer_get));

DEFAULT_VOLUME_SET=\
    Exec($(default_mixer_set) $(default_mixer_value));

% set $(kde4_app) before use
TEST_KDE4_APP=\
	Exec(V=`$(kde4_app) -v|grep KDE|tr -d " "|cut -f 2 -d ":"|cut -f 1 -d "."`; \
	     if [ "x$V" = "x3" ]; then \
	        $(CfgDir)/Utils/message.sh "ERROR: this configuration file is for KDE4"; \
	     fi);

SETUP_DEFAULT_POWER_MANAGEMENT=\
	Make(var,default_switch_off,by_value,poweroff);\
	Make(var,default_suspend,by_value,dbus-send --system --print-reply --dest="org.freedesktop.login1" /org/freedesktop/login1 org.freedesktop.login1.Manager.Suspend true);\
	Make(var,default_hibernate,by_value,dbus-send --system --print-reply --dest="org.freedesktop.login1" /org/freedesktop/login1 org.freedesktop.login1.Manager.Hibernate true);

% Use sleep 3 to get some time to receive disconnect response from client
DEFAULT_PC_SWITCHOFF=\
    Set(disconnect);\
	Exec(sleep 3;$(default_switch_off));

DEFAULT_PC_SUSPEND=\
    Set(disconnect);\
    Exec(sleep 3;$(default_suspend));

DEFAULT_PC_HIBERNATE=\
    Set(disconnect);\
    Exec(sleep 3;$(default_hibernate));
	
[Mode]=default_player_at

(EnterMode)=\
	Macro(SETUP_DEFAULT_POWER_MANAGEMENT);\
	Macro(RUN_IF_NEED);

Answer=\
    Make(disconnect);

Cancel=\
    Macro(QUIT);\
    Make(exit);

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

4=Macro(RWD);
5=Macro(PLAY);
6=Macro(FF);

7=Macro(PREV);
8=Macro(STOP);
9=Macro(NEXT);

* *=Macro(DEFAULT_HELP);
* #=Macro(RUN_OR_QUIT);
* 0=Macro(DEFAULT_PC_SUSPEND)
* 8=Macro(DEFAULT_PC_SWITCHOFF)
* 9=Macro(DEFAULT_PC_HIBERNATE)

0=Macro(PAUSE);
#=Macro(QUIT);

DEFAULT_HELP=\
    Exec(notify-send -t 5000 "1 Vol-  2 Mute  3 Vol+  4 Rew  5 Play  6 FF  7 Prew  8 Stop  9 Next * * Help  0 Pause  # Quit  * 0 Suspend  * 8 Switch Off  * 9 Hibernate");

DEFAULT_HELP_NO_FF_RWD=\
    Exec(notify-send -t 5000 "1 Vol-  2 Mute  3 Vol+  4 Not used  5 Play  6 Not used  7 Prew  8 Stop  9 Next * * Help  0 Pause  # Quit  * 0 Suspend  * 8 Switch Off  * 9 Hibernate");

InCall($$)=\
    Macro(PAUSE);

EndCall($$)=\
    Macro(PLAY);

[ModeEnd]

[End]
