Skip to content

Instantly share code, notes, and snippets.

@thomaswitt
Created October 25, 2016 17:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thomaswitt/199ed042f3b4cf777657d479825493e9 to your computer and use it in GitHub Desktop.
Save thomaswitt/199ed042f3b4cf777657d479825493e9 to your computer and use it in GitHub Desktop.
Switch HDMI output of Raspberry Pi devices off and on and preserve the X11 output
#!/bin/bash
if [ $# -lt 1 ]; then
echo "Syntax: $0 (on|off)"
exit
fi
if [ $1 == "on" ]; then
tvservice -p
sleep 2
chvt 6 && chvt 7
echo "Switched HDMI on"
fi
if [ $1 == "off" ]; then
tvservice -o
echo "Switched HDMI off"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment