Skip to content

Instantly share code, notes, and snippets.

@manoelstilpen
Created June 24, 2017 14:32
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 manoelstilpen/9bb1b382a2c2a9ec7e9aaf9d2f97da92 to your computer and use it in GitHub Desktop.
Save manoelstilpen/9bb1b382a2c2a9ec7e9aaf9d2f97da92 to your computer and use it in GitHub Desktop.
Script for changing brightness in Linux based systems
#!/bin/bash
# It's necessary give the correct permissions for the brightness file
# Verify the correct path to the brightness file on your pc
# Parameters: "inc" for increment and "dec" for decrement brightness
#get the current brightness
current=`cat /sys/class/backlight/intel_backlight/actual_brightness`
# sum or subtract 10 from current brightness
if [ "$1" == "inc" ]; then
current=$(expr $current + 10)
elif [ "$1" == "dec" ]; then
current=$(expr $current - 10)
fi
#save the current brightness
`echo $current > /sys/class/backlight/intel_backlight/brightness`
@manoelstilpen
Copy link
Author

Giving the correct permission: sudo chown your_user /sys/class/backlight/intel_backlight/brightness

Example usage for increment brightness in 10 units: ./brightness.sh inc 10

@eigan
Copy link

eigan commented Feb 19, 2019

Thanks for the script :)

You can also add this to your /etc/sudoers

<user> ALL= NOPASSWD: /usr/local/bin/<your-brightness-script>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment