Created
June 27, 2014 20:32
-
-
Save michaelneu/deaf8f0617728f33b907 to your computer and use it in GitHub Desktop.
Use Raspberry Pi as external network-monitor
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 | |
PI_IP="xxx.xxx.xxx.xxx" | |
LEFT_OF="VGA1" #"LVDS1" | |
CLIENT_SCRIPT_NAME="x11-client.sh" | |
LOCKFILE="/tmp/x11-extended-display-lock.pid" | |
screen_res='python -c "import Tkinter; r = Tkinter.Tk(); print r.winfo_screenwidth(), r.winfo_screenheight(); r.destroy();"' | |
d=`ssh pi@$PI_IP "export DISPLAY=:0 && $screen_res"` | |
case $1 in | |
client-gen) | |
own_ip=`hostname --ip-address` | |
ssh pi@$PI_IP -t "echo 'export DISPLAY=:0 && sleep 3 && xdotool mousemove 0 0 && vncviewer $own_ip -fullscreen' > $CLIENT_SCRIPT_NAME && chmod +x $CLIENT_SCRIPT_NAME" | |
exit;; | |
background) | |
if [ -e $LOCKFILE ] | |
then | |
echo "Process already running" | |
exit | |
else | |
echo $$ > $LOCKFILE | |
fi;; | |
*) | |
screen -S x11_server -d -m $0 background | |
exit;; | |
esac | |
ssh pi@$PI_IP "screen -S x11_client -d -m ./$CLIENT_SCRIPT_NAME" | |
mm=`cvt $d 60` | |
m=${mm##*Modeline } | |
mn="$( cut -d ' ' -f 1 <<< "$m" )" | |
xrandr --newmode $m | |
xrandr --addmode VIRTUAL1 $mn | |
xrandr --output VIRTUAL1 --mode $mn --left-of $LEFT_OF | |
x11vnc -display :0 -auth /var/lib/gdm/:0.Xauth | |
xrandr --output VIRTUAL1 --off | |
rm $LOCKFILE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment