Last active
August 29, 2015 14:08
-
-
Save loiclefloch/dd35c296b81221696e95 to your computer and use it in GitHub Desktop.
Change keyboard brightness on linux on Mac Book Pro
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 | |
file=/sys/devices/platform/applesmc.768/leds/smc::kbd_backlight/brightness | |
max_file=/sys/devices/platform/applesmc.768/leds/smc::kbd_backlight/max_brightness | |
level=$(cat $file) | |
changement_level=10 | |
function change_brightness | |
{ | |
echo $1 | |
echo $1 > $file | |
} | |
# Command line handler | |
case $1 in | |
up) | |
level=$((level+changement_level)) | |
;; | |
down) | |
level=$((level-changement_level)) | |
;; | |
disable) level=0 | |
;; | |
*) | |
echo "Usage: $0 { up | down | disable }" | |
exit | |
;; | |
esac | |
max=$(cat $max_file) | |
if [ $level -gt $max ]; then | |
level=$max | |
fi | |
if [ $level -lt 0 ]; then | |
level=0 | |
fi | |
change_brightness $level | |
#END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment