Skip to content

Instantly share code, notes, and snippets.

@dwf
Last active January 3, 2016 15:59
Show Gist options
  • Save dwf/8486406 to your computer and use it in GitHub Desktop.
Save dwf/8486406 to your computer and use it in GitHub Desktop.
Remedy my laptop's the annoying behaviour of setting an arbitrary brightness upon wake from sleep.
#!/bin/sh
# Script to restore the last value for brightness upon ACPI wake.
#
# Hilariously, while you can write a new brightness to
# /sys/class/backlight/intel_backlight/brightness,
#
# to accurately determine the current brightness you must use
# /sys/class/backlight/intel_backlight/actual_brightness,
case $(cat /proc/acpi/button/lid/LID0/state | awk '{print $2}') in
closed) cat /sys/class/backlight/intel_backlight/actual_brightness > /var/last_sleep_brightness ;;
open) cat /var/last_sleep_brightness > /sys/class/backlight/intel_backlight/brightness && rm -f /var/last_sleep_brightness ;;
esac
# /etc/acpi/events/brightness_restore
# For some reason my Acer Aspire TimelineX 1830T generates a battery event,
# with an identifiable code, when it wakes from sleep. I figured this out with
# acpi_listen. On sleep, it generates a button/lid event.
event=button/lid|battery BAT0 00000081
action=/etc/acpi/brightness_restore.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment