Change brightness percentage that screen brightness keys increase/decrease
SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Change brightness percentage that screen brightness keys increase/decrease
Hi,
I'd like to change percentage of brightness that the screen brightness keys increase/decrease the brightness.
On laptop A, which seems to have only 8 brightness levels. This laptop's 0 brightness level is actually 50%, which sucks. The keys increase/decrease by 1 unit (1/16 total brightness) from 100% down to 50%.
On laptop B, which has 1000 levels, the keys increase/decrease by seemingly 90 units (1/11 total brightness).
How, on laptop B at least, can I reduce the delta to 50?
Thanks.
Last edited by MozillaUser3172; 03-23-2020 at 05:18 PM.
I'm not sure on how you would go about redefining the increment amount for the brightness keys in the existing system. You could manage it with a script though. I had written a brightness script for an old MBP a while ago. I reworked the code so it could be called by a custom keyboard shortcut. In my system (KDE5) I just unbound the existing keyboard shortcut and then made a custom shortcut for the brightness keys, calling the script as follows:
Code:
sh <your script directory>/brightness_keys.sh up
or
Code:
sh <your script directory>/brightness_keys.sh down
brightness_keys.sh (note the comments)
Code:
#!/bin/sh
#
# brightness_keys.sh
#
# Adjusts the backlight in user specified increments
#
set -e
# Check what exists at your own /sys/class/backlight/* and
# adjust accordingly.
SYS_DIR="/sys/class/backlight/intel_backlight"
# Set your own desired increment here. E.g. 5% for 20 steps full scale
INCREMENT_PERCENT=5
MAX_BRIGHT=$(cat $SYS_DIR/max_brightness)
CUR_BRIGHT=$(cat $SYS_DIR/brightness)
INCREMENT_BRIGHT=$(( ($MAX_BRIGHT * $INCREMENT_PERCENT) / 100))
if ! [ -z "$1" ]; then
case "$1" in
"up")
if [ $(($CUR_BRIGHT + $INCREMENT_BRIGHT)) -ge $MAX_BRIGHT ]; then
# Ensures we always get up to 100
echo "$MAX_BRIGHT" > $SYS_DIR/brightness
else
echo "$(( $CUR_BRIGHT + $INCREMENT_BRIGHT ))" > $SYS_DIR/brightness
fi
;;
"down")
if [ $(($CUR_BRIGHT - $INCREMENT_BRIGHT)) -le 0 ]; then
# Ensures we always get down to 0
echo "0" > $SYS_DIR/brightness
else
echo "$(( $CUR_BRIGHT - $INCREMENT_BRIGHT ))" > $SYS_DIR/brightness
fi
;;
*)
echo "Proper usage: sh brightness_keys.sh (up|down)"
exit 1
;;
esac
else
echo "Proper usage: sh brightness_keys.sh (up|down)"
exit 1
fi
exit 0
Good luck!
I should note that this script is changing the value of /sys/class/backlight/<your_backlight_vendor>/brightness, while staying within its set limits. You could set it manually if you wish by echoing values into there.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.