Created
May 9, 2014 17:53
-
-
Save Ajnasz/79b95a45dd4763a84561 to your computer and use it in GitHub Desktop.
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/sh | |
# /etc/acpi/thinkpadbrightness.sh | |
# | |
# Script to change brightness of a ThinkPad t540p | |
# | |
# put this to /etc/acpi/events/thinkpad-brightness-down | |
# | |
# event=video/brightnessdown BRTDN 00000087 00000000 | |
# action=/etc/acpi/thinkpadbrightness.sh down | |
# | |
# put this to /etc/acpi/events/thinkpad-brightness-up | |
# | |
# event=video/brightnessup BRTUP 00000086 00000000 | |
# action=/etc/acpi/thinkpadbrightness.sh up | |
MIN_BRIGHTNESS=100 | |
CHANGES=20 | |
MAX_BRIGHTNESS=$(cat /sys/class/backlight/intel_backlight/max_brightness) | |
BRIGHTNESS=$(cat /sys/class/backlight/intel_backlight/brightness) | |
BRIGHTNESS_CHANGE=$(( $MAX_BRIGHTNESS / $CHANGES )) | |
DOWN_BRIGHTNESS=$(( $BRIGHTNESS - $BRIGHTNESS_CHANGE )) | |
UP_BRIGHTNESS=$(( $BRIGHTNESS + $BRIGHTNESS_CHANGE )) | |
if [ "x$1" = "xdown" ]; then | |
if [ "$DOWN_BRIGHTNESS" -lt "$MIN_BRIGHTNESS" ]; then | |
DOWN_BRIGHTNESS=$MIN_BRIGHTNESS | |
fi | |
echo $DOWN_BRIGHTNESS > /sys/class/backlight/intel_backlight/brightness | |
elif [ "x$1" = "xup" ]; then | |
if [ "$UP_BRIGHTNESS" -gt "$MAX_BRIGHTNESS" ]; then | |
UP_BRIGHTNESS=$MAX_BRIGHTNESS | |
fi | |
echo $UP_BRIGHTNESS > /sys/class/backlight/intel_backlight/brightness | |
else | |
echo >&2 Unknown argument $1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment