Last active
December 24, 2017 13:20
-
-
Save hfreire/ba77d2d2dd6a41730b9d to your computer and use it in GitHub Desktop.
Enable/disable your Raspberry PI HDMI output
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/sh | |
is_hdmi_output_off () | |
{ | |
tvservice -s | grep "TV is off" >/dev/null | |
} | |
case $1 in | |
stop) | |
tvservice -o | |
;; | |
start) | |
if is_hdmi_output_off | |
then | |
tvservice -p | |
curr_vt=`fgconsole` | |
if [ "$curr_vt" = "1" ] | |
then | |
chvt 2 | |
sleep 0.1 | |
chvt 1 | |
else | |
chvt 1 | |
sleep 0.1 | |
chvt "$curr_vt" | |
fi | |
fi | |
;; | |
status) | |
if is_hdmi_output_off | |
then | |
echo "HDMI output is off" | |
else | |
echo "HDMI output is on" | |
fi | |
;; | |
*) | |
echo "Usage: $0 start|stop|status" >&2 | |
exit 2 | |
;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment