• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Brightness Function Keys Issue

Riley Sutton

New Member


Messages: 1

#1
Hi.

I'll make this post short and sweet. I usually run linux on my laptop but am wondering if BSD would be able to work as well in terms of compatibility with the brightness keys. I have a Lenovo X260 and after installing arch realised that there was an issue with these functions keys not functioning without additional software running in the background. I usually use XFCE on with it's bundled power manager because it handles the brightness well but I don't want to be forced to use it if I chose to install another window manager. I've read about the xbrightness solution through keybinding but is there any other way to get these keys to function regardless of whether I'm running X11?

Thanks,
 

Eric A. Borisch

Well-Known Member

Thanks: 202
Messages: 310

#3
To get the brightness keys working on my x230 (including without X), I've followed the directions in acpi_ibm(4), which involves editing devd.conf (or /usr/local/etc/devd/*.conf) to match the ACPI/IBM event, and creating a /usr/local/sbin/acpi_oem_exec.sh to handle it. (This is all documented in the man page.)

However, I've had to replace the 0x10|0x11) case with the following:

Code:
    0x10)
        LVL=`sysctl -n hw.acpi.video.lcd0.brightness`
        LVL=$(((LVL / 10 + 1) * 10))
        sysctl hw.acpi.video.lcd0.brightness=${LVL}
        MESSAGE="LEVEL ${LVL}"
        ;;
    0x11)
        LVL=`sysctl -n hw.acpi.video.lcd0.brightness`
        LVL=$((((LVL + 1) / 10 - 1) * 10))
        [ ${LVL} -lt 10 ] && LVL=5
        sysctl hw.acpi.video.lcd0.brightness=${LVL}
        MESSAGE="LEVEL ${LVL}"
        ;;
It looks a little weird, but the valid levels (on mine) seem to actually be 5, 10, 20, ... 100; the combination of commands above provides those settings. Perhaps yours is similar...
 

Juha Nurmela

Well-Known Member

Thanks: 121
Messages: 401

#4
An old HP is different, the levels are not with constant interval. Not a big deal, but irritating.
I used this, most likely it could be smarter.

Juha

Code:
#!/bin/sh
#
# LCD backlight brightness
# Thu Aug 18 01:18:01 EEST 2016

base=hw.acpi.video.lcd0

avail="${base}.levels"
level="${base}.brightness"

was=`sysctl -n "$level"` || exit 1

case "$*" in
[0-9]*)
        was="$1"
        compare=-ge  # nearest would be better, but ...
        reverse=
        ;;
incr)
        compare=-gt
        reverse=
        ;;
decr)
        compare=-lt
        reverse=-r
        ;;
"")
        echo "$was" ; exit 0 ;;
*)
        echo "Usage: ${0##*/} PERCENT/incr/decr" >&2 ; exit 2 ;;
esac

sysctl -n "$avail" | tr ' ' '
' | sort -n $reverse | while read new
do
        if [ "$new" "$compare" "$was" ]
        then
                exec sysctl "$level=$new" > /dev/null
                exit
        fi
done

exit 1 # sad to report
 

Eric A. Borisch

Well-Known Member

Thanks: 202
Messages: 310

#5
An old HP is different, the levels are not with constant interval. Not a big deal, but irritating.
I used this, most likely it could be smarter.
My *.levels list includes 0, 1, .. 100, even though many of them don't really change anything, so unfortunately this approach wouldn't work.
 
Top