Skip to content

Instantly share code, notes, and snippets.

@AlexMoffat
Last active September 5, 2022 16:23
Show Gist options
  • Save AlexMoffat/b30adc679f0b860c165608606c580de2 to your computer and use it in GitHub Desktop.
Save AlexMoffat/b30adc679f0b860c165608606c580de2 to your computer and use it in GitHub Desktop.
raspberry pi turn on hdmi connected display. Use fbset -s to find the current values for xres and yres. You need to make some change to the fb values before the refresh call or nothing happens.
#!/bin/bash
set -o pipefail
tvservice -s | grep -q '\[TV is off\]'
if [[ $? -eq 0 ]]; then
# Turn display on.
/usr/bin/tvservice -p &> /dev/null
# Change color depth to 8 and back to 16.
/bin/fbset -xres 1920 -yres 1200 -depth 8
/bin/fbset -xres 1920 -yres 1200 -depth 16
# Now that something has changed refresh.
/usr/bin/xrefresh -d :0
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment