Variable substitution

In Exec(), Make(var,...), Load(), Include() commands is it possible to use internal "variables". Several of them are predefined.

Variables list

$(Home)

User home directory ($HOME) will be substituted instead of $(Home):

1=ExecAndSet(list,replace,Files in home,ls $(Home))

$(Mode)

Current mode will be substituted instead of $(Mode):

2=Make(mode,xmms);Exec(kdialog --msgbox "New mode is $(Mode)")

$(CfgDir)

Directory with configuration files substituted instead of $(CfgDir).

In most cases it is /usr/share/anyremote/cfg-data. Actually it depends on --prefix value which was used at build time.

It is posible to override this by using -cfgdir commandline option.

3=ExecAndSet(list,replace,Cfg Files,ls -1 $(CfgDir))

$(TmpDir)

Is is suggested to use $(TmpDir) in configuration files in commands which stores data in files.

Default value of $(TmpDir) variable is $HOME/.anyRemote.

It is posible to override this by using -tmpdir commandline option.

4=Exec(ls -1 $HOME > $(TmpDir)/home.list)

$(WaitSeconds)

This variable used to stop scripts started inside ExecAndSet(...) or Make(...) commands to avoid hang-up of anyRemote. If $(WaitSeconds) is set to positive value then after waiting for specified amount of seconds started script killed by SIGTERM signal.

Default value of $(WaitSeconds) variable is -1, that means it does not used.

(Init)=Make(var,WaitSeconds,by_value,30)

$(UpdateTimeout)

This variable used to control applocation state update timeout.

Default value of $(UpdateTimeout) variable is 5 seconds.

(Init)=Make(var,UpdateTimeout,by_value,3);

5=Macro(PLAY);Timer(UPDATE_STATE,$(UpdateTimeout),0);

$(AllowedOnly)

This variable used to setup access control. If $(AllowedOnly) is set to true then connection accepted only from hosts specified in file $HOME/.anyRemote/allowed_hosts file.

Default value of $(AllowedOnly) variable is false that means no access control is applied.

File $HOME/.anyRemote/allowed_hosts should contains allowed IP and Bluetooth addresses one address per line, for example:

192.168.1.1
127.0.0.1
0008F4163049

Access control can be applied to Bluetooth, TCP, Web server and XML services interfaces connection.

$(BtAddr)

[Server-mode only] $(BtAddr) variable will be substituted with bluetooth address of the phone after successful connection by J2ME/Android client.

If connection absent (or established not in Server mode through bluetooth) this variable will have empty value.

(Connect)=Exec(kdialog --msgbox "Connected by $(BtAddr)")

$(Bluez)

$(Bluez) variable will have value yes if anyRemote is compiled with Bluez support, or will have value no if anyRemote is compiled without Bluez support.

(Init)=Exec(kdialog --msgbox "anyRemote compiled with Bluez - $(Bluez)")

$(Xtest)

$(Xtest) variable will have value yes if anyRemote is compiled with XTest support, or will have value no if anyRemote is compiled without XTest support.

(Init)=Exec(kdialog --msgbox "anyRemote compiled with XTest - $(Xtest)")

$(MixerCard)

This variable is used in configuration files which are uses amixer utility to control sound volume.

$(MixerCard) variable will have default value 0. You can reset this variable to appropriate value if Your system have different sound card configuration.

(Init)=Make(var,MixerCard,by_value,1)

The most simple way to do this is to use hook_* files. So, just add command

Make(var,MixerCard,by_value,1)

to $HOME/.anyRemote/hook_init file.

Also, take a look at here

$(MixerChannel)

This variable is used in configuration files which are uses amixer utility to control sound volume.

$(MixerChannel) variable will have default value Master. You can reset this variable to appropriate value if Your system have different sound card configuration.

(Init)=Make(var,MixerChannel,by_value,PCM)

The most simple way to do this is to use hook_* files. So, just add command

Make(var,MixerChannel,by_value,PCM)

to $HOME/.anyRemote/hook_init file.

Also, take a look at here

Variables used to control internal behaviour of anyRemote

If You need to tune internal behaviour of anyRemote, then it is good idea to use these variable in (Init) event handler or in $HOME/.anyRemote/hook_init file.

$(Device)

This variable allows to specify connect string.

The same can be done by specifying -s ... command line parameter.

$(Device) variable will have default value bluetooth:19,tcp:5197,web:5080 (which is used in Server mode, so You have to care about this parameter in AT mode)

If anyRemote works as server correct then value for Device could be:

If anyRemote works in AT mode then correct value for Device could be:

where XX:XX:XX:XX:XX:XX is the bluetooth address of the phone and last Y is the channel number and where # is just a number

(Init)=Make(var,Device,by_value,rfcomm:00:12:EE:32:20:2B:1)

$(Logging)

Print or not to print logging info to the file $HOME/.anyRemote/anyremote.log.

$(Logging) variable can be set to false|true|debug and will have default value false.

Set it to debug for verbose logging.

The same can be done by specifying -log command line parameter.

(Init)=Make(var,Logging,by_value,debug);

By default all logging information stored in $HOME/.anyRemote/anyremote.log file. This could be altered by setting $(TmpDir) variable or -tmpdir commandline option.

If $(TmpDir) variable or -tmpdir commandline option are points outside of user home directory, then logging information will be printed to the file $(TmpDir)/anyremote.log.${USER}

$(ServiceName)

[Server mode over bluetooth only] This variable is used specify SDP service name.

$(ServiceName) variable have default value anyRemote

The same can be done by specifying -name ... command line parameter.

(Init)=Make(var,ServiceName,by_value,myName);

$(FromEncoding)

[Server mode only] Anyremote J2ME client supports only UTF8 encoding.

This variable is used to convert data from specified encoding to UTF8.

(Init)=Make(var,FromEncoding,by_value,ISO-8859-15);

Conversion from specified encoding to UTF8 will be automatically applied to the following commands:

ExecAndSet(list,add|replace,...);
ExecAndSet(iconlist,add|replace,...);
ExecAndSet(filemanager,add|replace,left|right...);
	

Reverse conversion to specified encoding from UTF8 will be automatically applied to the $(Param) environment variable.

$(ToEncoding)

[Server mode only]This variable is used along with $(FromEncoding). In most cases there are no needs to change it.

$(ToEncoding) variable have default value UTF-8

Variables used by web and XML services interfaces

$(ScreenSize)

[only by web interface] This variable should be set to minimal value of width and heigth of device screen size. Default value is 240.

(Init)=Make(var,ScreenSize,by_value,480)

$(RefreshPage)

[by web and XML services interfaces] This variable to automatically refresh page. Refresh rate should be specified in seconds. Default value is -1 that means no refresh.

(Init)=Make(var,RefreshPage,by_value,5)

$(IpAddr)

[only by XML services interface] This variable defines IP address of computer with anyRemote, which will be used in XML replyes. Default value is platform dependent.

Variables used only in AT-mode

$(AutoConnect)

[AT-mode only] This variable can be set to true or false and have default value false.

If value of this variable is true, then anyRemote will try to re-connect to phone automatically.

The same can be done by specifying -a command line parameter.

(Init)=Make(var,AutoConnect,by_value,true)

$(AutoRepeat)

[AT-mode only] This variable can be set to true or false and have default value false.

This variable is used to switch on/off auto repeat feature (as on PC keyboard - about 10 times per second). Useful for mouse and keyboard emulation.

(Init)=Make(var,AutoRepeat,by_value,true)

$(Baudrate)

[AT-mode only] Baudrate to use; default value is 19200

Possible values for Baudrate could be:

(Init)=Make(var,Baudrate,by_value,9600);

$(CharSet)

[AT-mode only] This variable will have default value 8859-1.

This variable allows to specify charset by AT+CSCS=... command.

(Init)=Make(var,CharSet,by_value,8859-1)

$(CmerOff)

[AT-mode only] This variable is used to tune AT+CMER=... command which exits phone from "echo" mode. In "echo" mode phone will send key codes of pressed buttons to anyRemote. This variable have no default value. If this variable is not set anyRemote will try to determine it automatically.

(Init)=Make(var,CmerOff,by_value,AT+CMER=0,0,0,0,0)

$(CmerOn)

[AT-mode only] Used when anyRemote is in AT-mode only.

This variable is used to tune AT+CMER=... command which enters phone in "echo" mode. In "echo" mode phone will send key codes of pressed buttons to anyRemote. This variable have no default value. If this variable is not set anyRemote will try to determine it automatically.

(Init)=Make(var,CmerOn,by_value,AT+CMER=3,2,0,0,0)

$(TwoWayComm)

[AT-mode only] Send or don't send any commands (SendCKPD(), etc.) to the phone. Can be set as true or false. Default value is false.

(Init)=Make(var,TwoWayComm,by_value,true)

$(RetrySeconds)

[AT-mode only] Duration in seconds beetween attempts to reconnect to the phone in case if connection fails. Default value is 60. Works in conjunction with AutoConnect parameter.

(Init)=Make(var,RetrySeconds,by_value,120);

$(ToMainMenu)

[AT-mode only] CKPD sequence which used to reach main screen of the phone from any of phone's menus. For example, on Motorola-V500 to press "Red Cancel" button is enough to get out from any menu.

If set, that sequence will be sent to phone after each key press. Default value is empty string. This parameter is a kind of shortcut which allows not to specify SendCKPD(E) command for each Key_Code.

(Init)=Make(var,ToMainMenu,by_value,E);

Variables used only in iViewer mode

$(IViewer)

[iViewer mode only] This variable can be set to true or false and have default value false.

If value of this variable is true, then anyRemote will use it as a hint to optimize handling of iViewer heartbeat messages.

(Init)=Make(var,IViewer,by_value,true)

Parametrized replies

[Server-mode only] There are $(Param) and $(Index) variables defined in handling command issued from anyRemote client menus. Use $$ inside braces to specify parametrized commands.

Choose($$)=Exec(xmmsctrl track $(Index));\
           Exec(kdialog --msgbox "Selected track is $(Param)")

User-defined variables

In addition to the predefined internal variables it is possible to define custom internal variables with Make(var,....) command.

5=Make(var,my_variable,by_value,3.141526);
5=Make(var,now_is,echo "Now is "`date`);