-
-
Save colesnicov/ba9173ea6a47aa5a41bd0c67fe27a218 to your computer and use it in GitHub Desktop.
Script to enable and disable the HDMI signal of the Raspberry PI
This file contains hidden or 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 -e | |
# /usr/local/sbin/raspi-monitor | |
# Script to enable and disable the HDMI signal of the Raspberry PI | |
# Inspiration: http://www.raspberrypi.org/forums/viewtopic.php?t=16472&p=176258 | |
CMD="$1" | |
function on { | |
/opt/vc/bin/tvservice --preferred | |
# Hack to enable virtual terminal nr 7 again: | |
chvt 6 | |
chvt 7 | |
} | |
function off { | |
/opt/vc/bin/tvservice --off | |
} | |
function must_be_root { | |
if [ $USER != root ]; then | |
echo "ERROR: Script must be executed as the root user" | |
exit 1 | |
fi | |
} | |
function main { | |
must_be_root | |
if [ "$CMD" == "on" ]; then | |
on | |
elif [ "$CMD" == "off" ]; then | |
off | |
else | |
echo "Usage: $0 <on|off>" | |
exit 1 | |
fi | |
exit 0 | |
} | |
main |
This file contains hidden or 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
# /etc/cron.d/raspi-monitor-scheduler | |
# Enable the monitor every weekday morning at 8:00 | |
0 8 * * 1,2,3,4,5 root /usr/local/sbin/raspi-monitor on > /dev/null 2>&1 | |
# Disable the monitor every weekday evening at 17:30 | |
30 17 * * 1,2,3,4,5 root /usr/local/sbin/raspi-monitor off > /dev/null 2>&1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment