#!/bin/bash # Screen cast your desktop to Apple TV (airplay). # Usage: airplay-client # Untested. Likely doesn't work. Airplay V1 only. if [[ "$SERVER_PORT" == "7000" ]]; then # We are the cgi script. echo 'Content-Type: video/h264' echo '' # TODO: figure out the correct video size ffmpeg -video_size 1920x1080 -framerate 30 -f x11grab -i :0.0 /dev/stdout else server="$1" client="$2" # launch our streaming server mkdir -p cgi-bin ln -sfn "$PWD/$0" cgi-bin/airplay python -m http.server --cgi --bind 0.0.0.0 7000 & trap EXIT ERR INT TERM "kill $!" # Tell the TV to pull down our video body="Content-Location: http://$client:7000/cgi-bin/airplay Start-Position: 0" curl "http://$server:7000/play" \ -v \ -H 'User-Agent: iTunes/10.6 (Macintosh; Intel Mac OS X 10.7.3) AppleWebKit/535.18.5' \ -H "Content-Length: $(wc -c "$body")" \ -h 'Content-Type: text/parameters' \ --data-raw "$body" wait fi