3

I own an Acer Aspire E5-773G notebook running Ubuntu 16.04 with Unity Desktop.

When I change the volume or screen brightness level (no matter whether using Fn+Arrows or through e.g. the Volume Indicator), the scaling does not seem natural.

There is nearly no notable difference between the steps in the upper third of the brightness scale and in the upper fourth of the volume scale.

On the other hand, the steps between slider positions in the lower third of the brightness scale and in the lower fourth of the volume scale seem huge. Especially the lowest brightness setting is extremely darker than the second lowest setting (but not off).

To me these scales seem technically linear, but as the human senses all operate logarithmically, they seem weird. Is there any method how I can change the scaling of mainly brightness and ideally also volume to a more logarithmic one so that the steps seem more equal?


Update:

The xbacklight tool does not work on my machine for whatever reason. However, I found two alternatives:

  • Dbus: You can use the two commands below to get/set the brightness value as percentage, i.e. integer number in the range 0-100:

    qdbus org.gnome.SettingsDaemon.Power /org/gnome/SettingsDaemon/Power org.gnome.SettingsDaemon.Power.Screen.GetPercentage
    qdbus org.gnome.SettingsDaemon.Power /org/gnome/SettingsDaemon/Power org.gnome.SettingsDaemon.Power.Screen.SetPercentage 42
    

    The advantage of this is that every user can run it without special privileges. It is less fine-grained though.

  • Direct access to /sys/...: You can use these commands to get/set the brightness level as raw integer number in the range of 0-x. The actual maximum value x can be found using the third command:

    cat /sys/class/backlight/intel_backlight/brightness
    echo 42 | sudo tee /sys/class/backlight/intel_backlight/brightness
    cat /sys/class/backlight/intel_backlight/max_brightness
    

    The advantage of this is that it provides direct access to the hardware capabilities, so this is the most fine-grained control we can get. Unfortunately, changing the brightness value requires root rights (note the sudo in the set-command).

  • Could you check if brightness shortcuts trigger any glib setting change using dconf watch /? – user.dz Jan 27 '17 at 8:28
1

That bothered me as well, at least for the brightness adjustment, so I wrote the following script (edit: alternative backlight control commands added in comments):

#!/bin/bash

current=`xbacklight -get`
# alternatively, if xbacklight does not work:
# current=`qdbus org.gnome.SettingsDaemon.Power /org/gnome/SettingsDaemon/Power org.gnome.SettingsDaemon.Power.Screen.GetPercentage`

scale="1 2 5 10 20 50 100"

case $1 in
    "down")
        # translate space to newline so tac will reverse order of lines (values)
        for val in $(tr ' ' '\n' <<< $scale | tac) ; do
            # scale = 3 to preserve some decimal values
            if (( $(bc <<< "scale=3 ; $val < $current/1.1") )) ; then
                newval=$val
                break
            fi
        done
        ;;
    "up")
        for val in $scale ; do
            # scale = 3 to preserve some decimal values
            if (( $(bc <<< "scale=3 ; $val > $current*1.1") )) ; then
                newval=$val
                break
            fi
        done
        ;;
    *)
        echo "Usage: $0 [up, down]"
        exit 1
esac

if [ "x$newval" == "x" ] ; then
    echo "Already at min/max."
else
    echo "Setting backlight to $newval."

    # thanks: https://bbs.archlinux.org/viewtopic.php?pid=981217#p981217
    notify-send " " -i notification-display-brightness-low -h int:value:$newval -h string:x-canonical-private-synchronous:brightness &

    xbacklight -set $newval -steps 1 -time 0
    # alternatively, if xbacklight does not work:
    # qdbus org.gnome.SettingsDaemon.Power /org/gnome/SettingsDaemon/Power org.gnome.SettingsDaemon.Power.Screen.SetPercentage $newval
fi

exit 0

It depends on having xbacklight installed.

Name it brightness.sh, and running brightness.sh up or brightness.sh down will step up or down through the scale specified at the top of the script. The call to notify-send triggers the on-screen brightness notification (at least in Unity). (I'm sure the script could be improved some, but it seems to work well enough.)

I then setup keyboard shortcuts (for my tablet's volume rocker buttons, in my case) to trigger /path/to/brightness.sh up and /path/to/brightness.sh down.

To do something similar for volume, you'd need to replace the calls to xbacklight with a command that lets you read/set the volume and change the notification to be a volume notification.

| improve this answer | |
  • Sorry for the delay, I have been a bit busy lately and forgot about your answer. Unfortunately, xbacklight has absolutely no effect on my system, it is neither able to get or set the backlight brightness value. I can access it though either by getting/setting the percentage using a dbus call, or by reading/writing the property directly into /sys/class/... as raw values as root. Edited my question with details about that. Can you please edit your script and replace xbacklight with one of the alternatives I presented? Thanks. – Byte Commander Jan 26 '17 at 22:02
  • I added the alternative commands as comments. Because xbacklight uses percentage values as well, they're simple drop-in replacements. I am not at a machine with Linux and a backlight, though, so I haven't tested them. – Mark L Jan 28 '17 at 1:36

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.