Created
August 31, 2017 05:22
-
-
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
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 | |
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