Skip to content

Instantly share code, notes, and snippets.

@andreaseger
Created July 14, 2013 01:49
Show Gist options
  • Save andreaseger/5992883 to your computer and use it in GitHub Desktop.
Save andreaseger/5992883 to your computer and use it in GitHub Desktop.
Asus UL80vt Brightness workaround
#!/bin/sh
# /etc/acpi/actions/backlight
#acpi_fakekey $KEY_BRIGHTNESSDOWN
# added per http://forum.notebookreview.com/showpost.php?p=5665108&postcount=1235
#brightness=`echo $3 | sed 's/0000002//'`
#setpci -s 00:02.0 F4.B=${brightness}f
# added per mailing-list post
STEP=0x16
DELAY=200000000
# Hacky Workaround to only use the first of the 4 fired events
LAST_RUN=`date --reference=/tmp/acpiBacklightTracker +%s%N 2> /dev/null`
if [ $? == 0 ]; then
TIME_NOW=`date +%s%N`
DIFF=$(($TIME_NOW - $LAST_RUN))
if [ $DIFF -le $DELAY ]; then
exit;
fi
fi
touch /tmp/acpiBacklightTracker
case $1 in
-)
brightness=$((0x`setpci -s 00:02.0 F4.B` - $STEP));
;;
+)
brightness=$((0x`setpci -s 00:02.0 F4.B` + $STEP));
;;
*)
brightness=$1
esac
if [ $brightness -lt 0 ] ; then
brightness=1;
fi
if [ $brightness -gt $((0xff)) ] ; then
brightness=$((0xff));
fi
setpci -s 00:02.0 F4.B=`printf '%x' $brightness`;
# /etc/acpi/events/brightnessup
event=video/brightnessup
action=/etc/acpi/actions/backlight +
# /etc/acpi/events/brightnessdown
event=video/brightnessdown
action=/etc/acpi/actions/backlight -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment