The hook, exec, and if commands on their own offer very little functionality with the possible exception of exec. However, combined, they allow the user to perform simple to complex Intercom tasks. A hook command for example, could call a shell script. It could even execute a command based on the exit-code of that script. In the following section, you will find some practical examples which demonstrate using these commands together. You may be able to use some of them as-is and some will need modifications.
Most people will probably want some sort of audio alert when an incoming call is received. Hooks make this very easy to implement. For this example, you will need a wave player such as bplay and a wave to play. Any wave will do but don't make it too long or you will have to wait before answering the call. The below example assumes that ring.wav resides in the sounds directory off of the home directory of the user running Intercom.
intercom: hook add call_incoming 'exec "bplay $HOME/sounds/ring.wav 1>/dev/null 2>&1 "'
Adding an audio alert when a call is terminated is fairly trivial and is left as an excersize for the reader.
If you often record from your Line input or another source, you will probably want Intercom to switch the OSS recording source to the mic input. The following simple example should do just this.
![]() | You will most likely need to adjust the cmix command below for the particular mixer you use. |
intercom: hook add call_connect 'exec "cmix rcs mic on"'
The following is a more complicated example which demonstrates a possible implementation of hooks and conditionals. Let's say you wanted to automatically reject calls before 08:00 and after 18:00. To accomplish this, you would use a hook command which looks something like the following.
intercom: hook add call_incoming "if \"test `date +%H` -lt 8 -o `date +%H` -gt 18\" hangup"
The date calls are expanded by Intercom to the values of the hour. This assumes you are using GNU date though and may have to be adjusted for other date implementations.