Created
May 28, 2022 13:01
-
-
Save indgy/913bc1fe2df5741c4a0b1e2bc8b2cf8a to your computer and use it in GitHub Desktop.
FreeBSD Lenovo Thinkpad screen brightness adjustments
This file contains hidden or 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 | |
# /usr/local/bin/acpi_brightness | |
# Credit: https://www.davidschlachter.com/misc/freebsd-acpi_video-thinkpad-display-brightness | |
CURRENT_LEVEL=`/sbin/sysctl -n hw.acpi.video.lcd0.brightness` | |
UP=$1 | |
if [ $UP == 1 ]; then | |
for i in 1 2 4 6 9 15 24 36 51 69 90 100; do | |
if [ "$CURRENT_LEVEL" -lt "$i" ]; then | |
/sbin/sysctl hw.acpi.video.lcd0.brightness=$i | |
exit | |
fi | |
done | |
fi | |
if [ $UP == 0 ]; then | |
for i in 100 90 69 51 36 24 15 9 6 4 2 1; do | |
if [ "$CURRENT_LEVEL" -gt "$i" ]; then | |
/sbin/sysctl hw.acpi.video.lcd0.brightness=$i | |
exit | |
fi | |
done | |
fi |
This file contains hidden or 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
# /usr/local/etc/devd/acpi_brightness.conf | |
notify 20 { | |
match "system" "ACPI"; | |
match "subsystem" "IBM"; | |
match "notify" "0x10"; | |
action "/usr/local/bin/acpi_brightness 1"; | |
}; | |
notify 20 { | |
match "system" "ACPI"; | |
match "subsystem" "IBM"; | |
match "notify" "0x11"; | |
action "/usr/local/bin/acpi_brightness 0"; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment