Skip to content

Instantly share code, notes, and snippets.

@jaz303
Last active May 6, 2017 10:37
Show Gist options
  • Save jaz303/4d54ad23443c6e8d81cc4a08ce3ea970 to your computer and use it in GitHub Desktop.
Save jaz303/4d54ad23443c6e8d81cc4a08ce3ea970 to your computer and use it in GitHub Desktop.
ACTION=="add", SUBSYSTEM=="backlight", RUN+="/bin/chgrp video /sys/class/backlight/%k/brightness"
ACTION=="add", SUBSYSTEM=="backlight", RUN+="/bin/chmod g+w /sys/class/backlight/%k/brightness"
#!/bin/bash
# script to adjust backlight brightness on thinkpad x250
# usage:
# ./backlight inc
# ./backlight dec
read max < /sys/class/backlight/intel_backlight/max_brightness
read cur < /sys/class/backlight/intel_backlight/actual_brightness
steps=10
per_step=$((max / steps))
current_step=$((cur / per_step))
if [ "$1" == "inc" ]
then
next_step=$((current_step + 1))
if [ $next_step -gt $steps ]
then
next_step=$steps
fi
elif [ "$1" == "dec" ]
then
next_step=$((current_step - 1))
if [ $next_step -lt "0" ]
then
next_step="0"
fi
fi
brightness=$((next_step * per_step))
notify-send -t 250 Brightness "${next_step}/${steps}"
echo $brightness > /sys/class/backlight/intel_backlight/brightness
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment