Created
October 25, 2012 13:32
-
-
Save cronnelly/3952563 to your computer and use it in GitHub Desktop.
Serve X display snapshot over HTTP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Call from inet with this config: | |
# www stream tcp nowait node /usr/local/bin/screen_serve.sh | |
export XAUTHORITY=/home/node/.Xauthority | |
export DISPLAY=:0 | |
filename="/tmp/screen-"$(uuidgen)".jpg" | |
for i in `seq 100`; do | |
read header | |
[ "$header" == $'\r' ] && break; | |
done | |
echo "HTTP/1.1 200 OK" | |
echo "Content-Type: image/jpeg" | |
/usr/bin/gm import -window root -quality 10 "$filename" | |
echo "Content-Length: "$(stat -c%s "$filename") | |
echo | |
cat "$filename" | |
echo | |
rm "$filename" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment