termux-packages/packages/termux-api/termux-infrared-transmit

29 lines
883 B
Bash
Executable File

#!/bin/sh
set -e -u
SCRIPTNAME=termux-infrared-transmit
show_usage () {
echo "Usage: $SCRIPTNAME -f frequency pattern"
echo "Transmit an infrared pattern. The pattern is specified in comma-separated on/off intervals, such as '20,50,20,30'. Only patterns shorter than 2 seconds will be transmitted."
echo " -f frequency IR carrier frequency in Hertz"
exit 0
}
FREQUENCY=""
while getopts :hf: option
do
case "$option" in
h) show_usage;;
f) FREQUENCY="--ei frequency $OPTARG";;
?) echo "$SCRIPTNAME: illegal option -$OPTARG"; exit 1;
esac
done
shift $(($OPTIND-1))
if [ -z "$FREQUENCY" ]; then echo "$SCRIPTNAME: No frequency specified"; exit 1; fi
if [ $# -lt 1 ]; then echo "$SCRIPTNAME: too few arguments"; exit 1; fi
if [ $# -gt 1 ]; then echo "$SCRIPTNAME: too many arguments"; exit 1; fi
@TERMUX_API@ InfraredTransmit $FREQUENCY --eia pattern $1