Skip to content

Instantly share code, notes, and snippets.

@mrngm
Created November 6, 2019 22:28
Show Gist options
  • Save mrngm/3e0dcce85486cdd2344876cd4e97b877 to your computer and use it in GitHub Desktop.
Save mrngm/3e0dcce85486cdd2344876cd4e97b877 to your computer and use it in GitHub Desktop.
#!/bin/bash
WIDTH=160
HEIGHT=75
X=0
Y=30
XDIR="r"
YDIR="b"
XOFFSET=150
YOFFSET=65
trap tarp SIGTERM SIGINT
# remove any leftover processes
function tarp() {
pkill png2ping
exit
}
while true; do
# send pings to (x,y)
/root/png2ping -file dvd.png -prefix "2001:610:1908:a000" -show-stats=false -offset-x ${X} -offset-y ${Y} -max-rate 220000 &
PID=$!
case "${XDIR}" in
r)
X=$((X + XOFFSET))
if [[ "$((X + WIDTH))" -ge 1920 ]]; then
X=$((1920 - WIDTH))
XDIR="l"
fi
;;
l)
X=$((X - XOFFSET))
if [[ "${X}" -le 0 ]]; then
X=0
XDIR="r"
fi
;;
esac
case "${YDIR}" in
t)
Y=$((Y - YOFFSET))
if [[ "${Y}" -le 0 ]]; then
Y=0
YDIR="b"
fi
;;
b)
Y=$((Y + YOFFSET))
if [[ "$((Y + HEIGHT))" -ge 1080 ]]; then
Y=$((1080 - HEIGHT))
YDIR="t"
fi
;;
esac
sleep 4
kill ${PID}
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment