Skip to content

Instantly share code, notes, and snippets.

@mingfang
Created August 31, 2017 05:22
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 mingfang/e0ed70428f78a225af5434b808f59d32 to your computer and use it in GitHub Desktop.
Save mingfang/e0ed70428f78a225af5434b808f59d32 to your computer and use it in GitHub Desktop.
script to turn off and on Raspberry Pi Display by detecting IP or bluetooth device
#!/bin/bash
while true
do
if ping -c 1 -w 3 192.168.2.67 &> /dev/null || hcitool scan | grep -q -E "ming-macbook|Ming's iPhone" ; then
echo "welcome back. turning screen on"
echo 0 | sudo tee /sys/class/backlight/rpi_backlight/bl_power
else
echo "you're gone. turning screen off"
echo 1 | sudo tee /sys/class/backlight/rpi_backlight/bl_power
fi
sleep 10
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment