# Brightness Function Keys Issue



## Riley Sutton (Apr 19, 2017)

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,


----------



## cpm@ (Apr 19, 2017)

See the references on the wiki page:

https://wiki.freebsd.org/Laptops/Thinkpad_X260

It seems that the Fn keys don't really work up to now but you can tinker with acpi_ibm(4) and acpi_video(4) to enable the brightness control.


----------



## Eric A. Borisch (Apr 21, 2017)

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:


```
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 (May 23, 2017)

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


```
#!/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 (May 23, 2017)

Juha Nurmela said:


> 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.


----------



## alx82 (Jun 16, 2018)

For Thinkpad x220/x230 users, I have submitted a patch to enable mic led on/off. One can listen to devd event, toggle the mic mixer state  and mic led state using dev.acpi_ibm.0.mic_led=1.

The patch can be found here https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=229074 .

I'm also working on more patches to enable FreeBSD acpi support on newer Thinkpad models (brightness keys, mic mute, etc...)


----------



## laufdi (Sep 8, 2019)

Can someone tell why the brightness is set to 100 after sleep sometimes (but sometimes not)? So when the screen goes on I get full brightness?

... the value of hw.acpi.video.lcd0.brightness is not really 100 but the brightness is full ...


----------



## Deleted member 30996 (Sep 8, 2019)

Here is the ThinkWiki page for the X260 showing keymapping and how to activate different functions.

When I'm looking to buy a Thinkpad this is where I check what options that model has.


----------



## laufdi (Sep 9, 2019)

What do you want to say?


----------



## George (Sep 9, 2019)

There are multiple brightness settings/sysctls.
Try this:
`sysctl -ad |grep lcd`
There are brightness levels for full power mode, economy mode, current brightness... So maybe try editing those?


----------



## laufdi (Sep 9, 2019)

I've already set  hw.acpi.video.lcd0.fullpower, economy and brightness to 10.
dev.acpi_ibm.0.lcd_brightness is 0


----------

