#!/usr/bin/env bash # exit if a command fails set -o errexit # select which source to switch to if [ "$#" -ne 1 ]; then echo -e "\\nUsage: $0 \\n" exit 1 fi # select which device to talk to via cec DEVICE="0.0.0.0" # if input is 0 and tv is on, turn off tv if [ "$1" == "0" ]; then echo "standby ${DEVICE}" | cec-client -s -d 1 else echo "on ${DEVICE}" | cec-client -s -d 1 echo "tx 4F:82:{$1}0:00" | cec-client -s fi