Skip to content

Instantly share code, notes, and snippets.

@kopiro
Last active December 19, 2020 15:51
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 kopiro/0ac66924c175acdf719e79da56bf0f87 to your computer and use it in GitHub Desktop.
Save kopiro/0ac66924c175acdf719e79da56bf0f87 to your computer and use it in GitHub Desktop.
Apple TV on Raspberry PI emulator
#!/bin/bash
pkill -f rpiplay
pkill -f simple-atv-aerial
rpiplay -n Mela -a hdmi -b auto -I &
simple-atv-aerial &
connected=0
while true; do
if lsof -i -sTCP:ESTABLISHED | grep rpiplay >/dev/null ; then
if [ $connected -eq 0 ]; then
echo "A device has connected!"
echo "Killing screensaver"
pkill -f simple-atv-aerial
# 4F:82:{1,2,3,4}0:00 = HDMI{1,2,3,4}
echo "Changing TV source"
echo "tx 4F:82:30:00" | cec-client -s -d 1
echo "Switching ON TV"
echo 'on 0' | cec-client -s -d 1
echo "Changing TV source, again"
echo "tx 4F:82:30:00" | cec-client -s -d 1
connected=1
fi
else
# If we have switched on the TV, start the screensaver!
if [ $connected -eq 1 ]; then
connected=0
pkill -f simple-atv-aerial
simple-atv-aerial &
fi
fi
sleep 1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment