diff options
Diffstat (limited to 'abs/core/LinHES-system/change_channel.sh')
-rwxr-xr-x | abs/core/LinHES-system/change_channel.sh | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/abs/core/LinHES-system/change_channel.sh b/abs/core/LinHES-system/change_channel.sh new file mode 100755 index 0000000..819076a --- /dev/null +++ b/abs/core/LinHES-system/change_channel.sh @@ -0,0 +1,71 @@ +#!/bin/sh +# Maintained by CommandIR Support mini at commandir.com - Comments / Suggestions Welcome. +# Modified for LinHES specifics +echo $@ > /tmp/change_channel.log +if [ $# -lt 2 ] +then + echo "IR Control Script for LIRC V2.0 +Includes support for CommandIR transmitter selection and lockfile. +The remote codes will be specific to the transmitter number and matched via /etc/systemconfig +Usage: +$0 TRANSMITTER_NUM (CHANNEL_NUMBER | IR_COMMAND) [DELAY] + +Sends an IR command or sequence of numbers using REMOTE_NAME via emitter +TRANSMITTER_NUM. DELAY (in seconds) is waited between sending IR commands. + +Example: Change to channel 123 using emitter 2 with a 0.3s pause between digits: +$0 1 123 .3 + +" + exit 1 +fi + +if [ $# -eq 3 ] +then + DELAY=$3 +else + DELAY=.2 +fi + +. /etc/systemconfig + + +LOCKFILE=/tmp/lirclock +export PATH=/bin:/usr/bin:/usr/local/bin + +TRANSMITTER=$1 +#get remote name from system config +tname="HostTransmitproto_$TRANSMITTER" +REMOTE_NAME=${!tname} +if [ x$REMOTE_NAME = "xnone" ] +then + echo "Please define Transmitters in /etc/systemconfig" + exit 1 +fi + +cmd="$2" + + +while [ -f $LOCKFILE ] +do + echo "Waiting for change channel lock file..." + sleep .1 +done + +touch $LOCKFILE + +irsend SET_TRANSMITTERS $TRANSMITTER +sleep .15 +case $cmd in + [0-9]*) + for digit in $(echo $2 | sed -e 's/./& /g'); do + irsend SEND_ONCE $REMOTE_NAME $digit + sleep $DELAY + done + ;; + + *) + irsend SEND_ONCE $REMOTE_NAME $cmd + ;; +esac +rm -f /tmp/lirclock
\ No newline at end of file |