Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 2 Mar 2020 09:29:33 +0100
From:      Michael Gmelin <grembo@freebsd.org>
To:        Kevin Oberman <rkoberman@gmail.com>
Cc:        x11-list freebsd <freebsd-x11@freebsd.org>
Subject:   Re: Unexpected fallout of evdev
Message-ID:  <20200302092933.573a3479@bsd64.grem.de>
In-Reply-To: <CAN6yY1sOaWjO%2B2ktex7P=pmBd%2BR86vLnGxAniMCtL7UaDZpo-w@mail.gmail.com>
References:  <CAN6yY1sOaWjO%2B2ktex7P=pmBd%2BR86vLnGxAniMCtL7UaDZpo-w@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help


On Fri, 28 Feb 2020 09:46:44 -0800
Kevin Oberman <rkoberman@gmail.com> wrote:

> This is odd enough that I am uncomfortable opening a ticket. it makes
> little sense to me.
> 
> Since I updated to xorg-server-1.20.7 with attendant transition to
> evdev and updating to mesa-19.0.8, I can no longer adjust my LCD
> brightness from my keyboard. I tried xev pressing Fn does generate
> press and release events but  Fn-Home and Fn-End, the brightness
> control keys on my ThinkPad T520, produce no event and no change to
> the brightness. I can still adjust brightness with sysctl.
> 
> Other Fn combinations, such as turning the ThinkLight on and off
> work, but I know that some of these are processed by ACPI/EC without
> OS involvement.
> ...

We discussed this off-list and found a solution. It works in vtys
as well as in xorg. For completeness sake, this is how we did it
(assumes you're using /bin/sh or bash):

1. Load acpi_ibm:

kldload acpi_ibm
sysrc kld_list+=acpi_ibm

2. Install intel-backlight package

pkg install intel-backlight

3. Create /etc/devd/thinkpad.conf

fetch -o /etc/devd https://blog.grem.de/thinkpad.conf

or

cat >/etc/devd/thinkpad.conf<<"EOF"
notify 10 {
	match "system" "ACPI";
	match "subsystem" "IBM";
	action "/usr/local/sbin/thinkpad_extra_keys.sh $notify";
};
EOF

4. Create /usr/local/sbin/thinkpad_extra_keys.sh

fetch -o /usr/local/sbin https://blog.grem.de/thinkpad_extra_keys.sh

or

cat >/usr/local/sbin/thinkpad_extra_keys.sh<<"EOF"
#!/bin/sh

if [ "$1" = "" ]
then
	echo "usage: $0 notify"
	exit 1
fi

case $1 in
	0x05)
		LEVEL=$(sysctl -n dev.acpi_ibm.0.bluetooth)
		if [ "$LEVEL" = "1" ]
		then
			sysctl dev.acpi_ibm.0.bluetooth=0
			MESSAGE="bluetooth disabled"
		else
			sysctl dev.acpi_ibm.0.bluetooth=1
			MESSAGE="bluetooth enabled"
		fi
		;;
	0x10)
		MESSAGE=$(/usr/local/bin/intel_backlight incr)
		;;
	0x11)
		MESSAGE=$(/usr/local/bin/intel_backlight decr)
		;;
	*)
		MESSAGE="UNKNOWN EVENT $1"
		;;
esac
logger thinkpad_extra_keys: ${MESSAGE}
exit 0
EOF

5. Mark /usr/local/sbin/thinkpad_extra_keys.sh executable

chmod 755 /usr/local/sbin/thinkpad_extra_keys.sh

6. Restart devd

This should do the trick and allow brightness control to work inside
and outside of X.

There are more things that can be controlled in there
(see `man 4 acpi_ibm').

Cheers,
Michael

-- 
Michael Gmelin



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20200302092933.573a3479>