Skip to content

Instantly share code, notes, and snippets.

@hfreire
Last active December 24, 2017 13:20
Show Gist options
  • Save hfreire/ba77d2d2dd6a41730b9d to your computer and use it in GitHub Desktop.
Save hfreire/ba77d2d2dd6a41730b9d to your computer and use it in GitHub Desktop.
Enable/disable your Raspberry PI HDMI output
#!/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