Created
October 24, 2017 21:24
-
-
Save vahit/3f42e9dd2b7cd40f2537621745332970 to your computer and use it in GitHub Desktop.
backlight controller in Archlinux
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/sbin/env bash | |
set -exuo pipefail | |
# Backlight controller | |
# IMPORTANT!! | |
# YOU MUST RUN THESE TWO COMMANDS AFTER EVERY REBOOT SINCE I FIND A PROPER SOLUTION. | |
# # chown root:user sys/class/backlight/intel_backlight/max_brightness | |
# # chmod 664 sys/class/backlight/intel_backlight/max_brightness | |
# USAGE: | |
# backlightc.sh command step | |
# | | | |
# inc: increase <-| |-> inc/dec step lenght | |
# dec: decrease <-| | |
max_backlight=$(< /sys/class/backlight/intel_backlight/max_brightness) | |
min_backlight=0 | |
brightness="/sys/class/backlight/intel_backlight/brightness" | |
current_backlight=$(< ${brightness}) | |
step=${2} | |
function decrease() { | |
current_backlight=$((current_backlight - step)) | |
if [[ ${current_backlight} -le ${min_backlight} ]]; then | |
current_backlight=1 | |
fi | |
tee "${brightness}" <<< ${current_backlight} | |
} | |
function increase() { | |
current_backlight=$((current_backlight + step)) | |
if [[ ${current_backlight} -gt ${max_backlight} ]]; then | |
current_backlight=${max_backlight} | |
fi | |
tee "${brightness}" <<< "${current_backlight}" | |
} | |
case $1 in | |
inc) | |
increase | |
exit 0;; | |
dec) | |
decrease | |
exit 0;; | |
*) | |
echo "${current_backlight}";; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment