Skip to content

Instantly share code, notes, and snippets.

@quelleck
Forked from AGWA/rpi-hdmi.sh
Last active Sep 11, 2022
Embed
What would you like to do?
Enable and disable the HDMI port on the Raspberry Pi: `rpi-hdmi on` to turn on, `rpi-hdmi off` to turn off.
#!/bin/sh
# Enable and disable HDMI output on the Raspberry Pi
is_off ()
{
vcgencmd display_power | grep "display_power=0" >/dev/null
}
case $1 in
off)
if is_off
then
echo Already off...
else
vcgencmd display_power 0
fi
;;
on)
if is_off
then
vcgencmd display_power 1
else
echo Already on...
fi
;;
status)
if is_off
then
echo off
else
echo on
fi
;;
*)
echo "Usage: $0 on|off|status" >&2
exit 2
;;
esac
exit 0
@ShadGates
Copy link

ShadGates commented Apr 27, 2019

Nice! Using this, instead of the original rpi-hdmi.sh, works with my HDMI-to-DVI adapter-connected to an old monitor, where the original could turn it off, but not back on again.

@cwpollock
Copy link

cwpollock commented Jan 3, 2020

This one worked for me too! Thanks!

@CzarLucius
Copy link

CzarLucius commented Sep 20, 2020

I am still struggling with this. Copied and pasted the code above into a new .sh file - file path: /home/pi Went into the crontab and the time came and went. I have repeated the steps multiple times to no avail - any known bugs with Pi 3 B+? Do I need to run the cron as a super user?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment