Re: Unexpected fallout of evdev

Michael Gmelin <[email protected]>
Newsgroups gmane.os.freebsd.devel.x11
Message-ID <[email protected]>

On Fri, 28 Feb 2020 09:46:44 -0800
Kevin Oberman <[email protected]> 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
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-x11
To unsubscribe, send any mail to "[email protected]"
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.