Skip to content

Instantly share code, notes, and snippets.

@zellio
Last active December 27, 2015 22:43
Show Gist options
  • Save zellio/4c932a30a9332d36dc0d to your computer and use it in GitHub Desktop.
Save zellio/4c932a30a9332d36dc0d to your computer and use it in GitHub Desktop.
Video Brightness Control for acpid
#!/usr/bin/env bash
bl_dir='/sys/class/backlight/intel_backlight/'
bl_dev="$bl_dir/brightness"
bl_index='/var/acpi/backlight/index'
max_brightness="$(<"${bl_dir}/max_brightness")"
min_brightness=82
min_index=0
max_index=12
index="$(<"$bl_index")"
(( step = (max_brightness - min_brightness) / (max_index - min_index) ))
case "$2" in
BRTUP)
(( index = index + 1 ))
if (( index > max_index )); then
(( index = max_index ))
fi
;;
BRTDN)
(( index = index - 1 ))
if (( index < min_index )); then
(( index = min_index ))
fi
;;
esac
echo -n "$index" > "$bl_index"
echo -n "$(( index * step + min_brightness ))" > "$bl_dev"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment