Skip to content

Instantly share code, notes, and snippets.

@h6y3
Last active May 17, 2017 13:30
Show Gist options
  • Save h6y3/8a4c62441ce7a39b4a8031fef171db4b to your computer and use it in GitHub Desktop.
Save h6y3/8a4c62441ce7a39b4a8031fef171db4b to your computer and use it in GitHub Desktop.
Ruby script to turn Raspberry Pi 7" LCD on or off
#!/usr/bin/ruby
# Example usage: ./rpi-lcd.sh --power=on
args = Hash[ ARGV.join(' ').scan(/--?([^=\s]+)(?:=(\S+))?/) ]
power = args["power"]
if power == "on"
%x(sudo bash -c "echo 0 > /sys/class/backlight/rpi_backlight/bl_power")
elsif power == "off"
%x(sudo bash -c "echo 1 > /sys/class/backlight/rpi_backlight/bl_power")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment