diff options
author | James Meyer <james.meyer@operamail.com> | 2012-10-11 14:44:17 (GMT) |
---|---|---|
committer | James Meyer <james.meyer@operamail.com> | 2012-10-11 14:44:17 (GMT) |
commit | 3558cfb46c2019697b12e449f3a42e00a84bf1a3 (patch) | |
tree | 9d490b2b5ac37f144ab0f58b51a5d7f7a14e1bda | |
parent | 4f945ba715a09fb2425e3a40e9bb1783e45f86c5 (diff) | |
download | linhes_pkgbuild-3558cfb46c2019697b12e449f3a42e00a84bf1a3.zip linhes_pkgbuild-3558cfb46c2019697b12e449f3a42e00a84bf1a3.tar.gz linhes_pkgbuild-3558cfb46c2019697b12e449f3a42e00a84bf1a3.tar.bz2 |
LinHES-system: more work with change_channel.sh
This version uses getops instead of position based.
-d delay
-c channel
-n transmitter #
-s key to send after the channel, like Enter
-rwxr-xr-x | abs/core/LinHES-system/PKGBUILD | 4 | ||||
-rwxr-xr-x | abs/core/LinHES-system/change_channel.sh | 205 |
2 files changed, 152 insertions, 57 deletions
diff --git a/abs/core/LinHES-system/PKGBUILD b/abs/core/LinHES-system/PKGBUILD index dc31936..ef6bf08 100755 --- a/abs/core/LinHES-system/PKGBUILD +++ b/abs/core/LinHES-system/PKGBUILD @@ -1,6 +1,6 @@ pkgname=LinHES-system pkgver=2 -pkgrel=117 +pkgrel=118 arch=('i686' 'x86_64') MVDIR=$startdir/pkg/usr/LH BINDIR=$startdir/pkg/usr/bin @@ -110,7 +110,7 @@ md5sums=('5bd4938cf41b63787aa4cdfd76423e09' '45f46d1f9193c8dde18e56369ec29a1e' 'a8edbe7bc37e9932e8749d9f5f89c16f' '116b0f62ed4e8dd6e437930deeb6e49e' - 'd173f98728e436a5180f56e888c2bf91' + '0ca244610ab1f68f70a8af0ddefee277' 'bacc813b48bafcc6fe906e5969930501' 'eb879fee9603a05d5420d4ce8ed9e450' 'f1870a9522c79e6b248fcbf81dec3280' diff --git a/abs/core/LinHES-system/change_channel.sh b/abs/core/LinHES-system/change_channel.sh index 819076a..3337785 100755 --- a/abs/core/LinHES-system/change_channel.sh +++ b/abs/core/LinHES-system/change_channel.sh @@ -1,71 +1,166 @@ -#!/bin/sh +#!/bin/bash # 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 +echo $@ > /tmp/change_channel.log . /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" +function change_channel() { + touch $LOCKFILE + irsend SET_TRANSMITTERS $TRANSMITTER + sleep .15 + case $cmd in + [0-9]*) + for digit in $(echo $cmd | sed -e 's/./& /g') + do + irsend SEND_ONCE $REMOTE_NAME $digit + sleep $DELAY + done + if [ x$SENDKEY != "x" ] + then + irsend SEND_ONCE $REMOTE_NAME $SENDKEY + fi + + ;; + + *) + irsend SEND_ONCE $REMOTE_NAME $cmd + ;; + esac +} + +function showhelp(){ + echo "IR Control Script for LIRC + 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 -d delay -c channel -n transmitter_number -s Enter + + -d delay in tenths of a seconds - + -c channel or cmd + -n transmitter_number + -s Key to send after executing change channel command (optional) + + Sends an IR command or sequence of numbers using via emitter TRANSMITTER_NUM. + DELAY ( in 10th of seconds) is waited between sending IR commands. + + Example: Change to channel 123 using emitter 2 with a 0.3s pause between digits: + $0 -n1 -c123 -d3 + + " + exit 1 + + +} + +function testvars() { + if [ x$DELAY = "x" ] + then + tdelay="HostTransmitDelay_$TRANSMITTER" + d=${!tdelay} + DELAY=$(echo "scale=2; $d / 10" | bc) + fi + + + if [ x$cmd = "x" ] + then + echo "-c is mandatory" + exit 1 + fi + + + if [ x$TRANSMITTER = "x" ] + then + echo "-n is mandatory" + exit 1 + fi + echo "delay is $DELAY" + + +# echo "channel or button name is $cmd" +# echo "Using transmitter $TRANSMITTER" +# echo "Remote name is $REMOTE_NAME" +# echo "Will send key $SENDKEY after numbers" +} + + +#-----------------------------Main Program----------------------- + +while getopts ":d:c:n:hs:" opt; do + case $opt in + h) showhelp + ;; + d) DELAY=$(echo "scale=2; $OPTARG / 10" | bc) + ;; + + c) cmd=$OPTARG + ;; + + n) TRANSMITTER=$OPTARG + tname="HostTransmitproto_$TRANSMITTER" + REMOTE_NAME=${!tname} + if [ x$REMOTE_NAME = "xnone" ] + then + echo "Please define Transmitters in /etc/systemconfig" + exit 1 + fi + if [ x$REMOTE_NAME = "x" ] + then + echo "Please define Transmitters in /etc/systemconfig" + exit 1 + fi + + ;; + + s) SENDKEY=$OPTARG + ;; + + \?) + echo + echo "Invalid option: -$OPTARG" >&2 + exit 1 + ;; + :) + echo + echo "Option -$OPTARG requires an argument." >&2 + exit 1 + ;; + esac +done + +testvars while [ -f $LOCKFILE ] do - echo "Waiting for change channel lock file..." - sleep .1 + echo "Waiting for change channel lock file..." + sleep .1 done -touch $LOCKFILE +change_channel +rm -f /tmp/lirclock + + + + + + + + + + + + + + + + + + + + -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 |