Skip to content

Instantly share code, notes, and snippets.

@teolandon
Created August 30, 2017 03:54
Show Gist options
  • Save teolandon/f6e9a3d6b584f7287b4f05d2a1d9b968 to your computer and use it in GitHub Desktop.
Save teolandon/f6e9a3d6b584f7287b4f05d2a1d9b968 to your computer and use it in GitHub Desktop.
intel_backlight brightness control scripts.
#!/bin/bash
# Takes an input of a number, to subtract from the current brightness.
DIR=/sys/class/backlight/intel_backlight
LVL=$1
MIN=100
CURR=$(head -n 1 "$DIR/brightness")
NEW=$(($CURR-$LVL))
if [ "$NEW" -lt "$MIN" ]; then
tee "$DIR/brightness" <<< $MIN > /dev/null
exit
else
tee "$DIR/brightness" <<< $NEW > /dev/null
fi
#!/bin/bash
# My laptop's brightness control doesn't automatically work
# by itself, and xbacklight is looking in the wrong directory
# to change my backlight settings, so I quickly wrote up these
# scripts to bindsym them to my brightness control keys. Simple
# and clean.
# Make sure that whatever you're using to call them has sufficient
# perimissions.
# Takes an input of a number, to add to the current brightness.
DIR=/sys/class/backlight/intel_backlight
LVL=$1
MAX=$(head -n 1 "$DIR/max_brightness")
CURR=$(head -n 1 "$DIR/brightness")
NEW=$(($LVL+$CURR))
if [ "$NEW" -gt "$MAX" ]; then
tee "$DIR/brightness" <<< $NEW > /dev/null
exit
else
tee "$DIR/brightness" <<< $NEW > /dev/null
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment