Skip to content

Instantly share code, notes, and snippets.

@pavax
Last active July 24, 2023 21:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pavax/b87be45221a8230d767c979a65409080 to your computer and use it in GitHub Desktop.
Save pavax/b87be45221a8230d767c979a65409080 to your computer and use it in GitHub Desktop.
cec-tv-status.sh
#/bin/bash
if [[ $1 == "turn-on" ]]; then
command=$(echo 'on 0.0.0.0' | cec-client -s -d 1)
elif [[ $1 == "turn-off" ]]; then
command=$(echo 'standby 0.0.0.0' | cec-client -s -d 1)
elif [[ $1 == "status" ]]; then
#command=$(echo 'pow 0.0.0.0' | cec-client -s -d 1)
readarray -t lines < <(echo 'pow 0.0.0.0' | cec-client -s -d 1)
if [[ ${lines[1]} == *"on"* ]]; then
echo "on"
exit 0
else
echo "off"
exit 1
fi
elif [[ $1 == "tx" ]]; then
command=$(echo 'tx' $2 | cec-client -s -d 1)
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment