Last active
October 4, 2017 16:46
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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