Skip to content

Instantly share code, notes, and snippets.

@djmason9
Forked from AGWA/rpi-hdmi.sh
Created February 17, 2020 16:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save djmason9/ee0f29c680a0a46bbb0d452eba2a5c64 to your computer and use it in GitHub Desktop.
Save djmason9/ee0f29c680a0a46bbb0d452eba2a5c64 to your computer and use it in GitHub Desktop.
Enable and disable the HDMI port on the Raspberry Pi: `rpi-hdmi on` to turn on, `rpi-hdmi off` to turn off. X is properly reinitialized when re-enabling.
#!/bin/sh
# Enable and disable HDMI output on the Raspberry Pi
is_off ()
{
tvservice -s | grep "TV is off" >/dev/null
}
case $1 in
off)
vcgencmd display_power 0
;;
on)
vcgencmd display_power 1
;;
status)
if is_off
then
echo off
else
echo on
fi
;;
*)
echo "Usage: $0 on|off|status" >&2
exit 2
;;
esac
exit 0
@djmason9
Copy link
Author

A better way to shut off Raspberry pi screen (tested on raspberry pi 4)

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