Skip to content

Instantly share code, notes, and snippets.

@ajmas
Last active October 4, 2017 16:46
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 ajmas/831f492cc7069121dacfe708f0b851fc to your computer and use it in GitHub Desktop.
Save ajmas/831f492cc7069121dacfe708f0b851fc to your computer and use it in GitHub Desktop.
Script for turning on and off a connected screen, on a Raspberry Pi
#!/bin/bash
## script for turning and off the connected screen
## taken from https://www.raspberrypi.org/forums/viewtopic.php?t=7570
if [ $1 = 'on' ]; then
tvservice -p
fbset -depth 8
fbset -depth 16
fbset -depth 32
chvt 6
chvt 7
# added to deal with desktop not redrawing
export DISPLAY=:0
xrefresh
echo 'Switched Screen ON!'
fi
if [ $1 = 'off' ]; then
tvservice -o
echo 'Switched Screen OFF!'
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment