0

I would like to know how to set threshold brightness that can be adjusted via the brightness keys (F11, F12) in my case.

When I press F11, the brightness is going too minimum that it ends up in black screen (exactly 0 brightness).

For example, in Windows 8.1, decreasing the brightness via F11, even if the indicator shows 0, it isn't actually 0 but some value which is visible.

P.S:

xbacklight sets the brightness to low, but it needs to start at the system startup which I've done. It is OK. But, what I want is not a brightness at startup, but adjusting of brightness with the keys, so that the minimum brightness which I set shouldn't go to exactly 0 even if the slider shows 0.

See, when the brightness is adjusted with the Power Manager indicator in Xfce, even if the Slider shows 0, the brightness is set to a value that is not exactly 0 but something reasonable. It's value is 0.533618 (which I got using xbacklight). This value I would like to have as threshold.

So, how to set this value as threshold value for brightness.

P.S: I don't want to install any additional software for this.

  • I have a script I wrote for my wife's laptop that does just what you're looking for. I don't have it with me right now. I'll plan to post in the next few days. – jbrock Nov 10 '16 at 19:15
0

The usage for the following script is script-name -d to decrease brightness and script-name -u to increase brightness. You can set a keyboard shortcut for F11 and F12 respectively. I believe the keyboard shortcut will override your current use for those two keys. Remember to make it executable by running the command chmod +x script-name. It is possible that the file that controls your brightness is not /sys/class/backlight/acpi_video0/brightness. It could be something very similar though such as in the directory acpi_video1 instead. It might take a little digging around.

#!/bin/bash

file="/sys/class/backlight/acpi_video0/brightness"

num=$(cat "$file")

case $1 in
    -u)
        ((num++)) ;;
    -d)
        ((num--)) ;;
    *)
        echo "This is not an option." ;;
esac

if [ "$num" = 10 ]; then
    notify-send "You are at max brightness."
    exit 1
fi

if [ "$num" = -1 ]; then
    notify-send "You are at minimum brightness."
    exit 1
fi

echo "$num" > "$file"

You will need to add the following to /etc/rc.local before exit 0.

chown username:username /sys/class/backlight/acpi_video0/brightness

Replace username with the output of the command echo $USER. You need to run the above command or reboot with this line in /etc/rc.local before the above script will work. Adding the line to /etc/rc.local is necessary because eventually on reboot, brightness will change to root ownership again. Then the above script won't be able to write to it. Please let me know if any issues come up.

  • Error: brightness.sh: 11: brightness.sh: num--: not found – user12458 Nov 13 '16 at 11:35
  • That is OK. But how to bind it to brightness indicator (with progressbar) like we get usually a slider showing the brightness? – user12458 Nov 13 '16 at 11:48
  • @JavaTechnical Did it work for you? Is the only issue that it is not showing the notification slider? – jbrock Nov 13 '16 at 23:44
  • Yes. It must show in the brightness slider (not just show some notification as in the above code). – user12458 Nov 14 '16 at 6:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.