[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Fn keys not working in Debian 12 on Lenovo Thinkpad T450s



On Thu, Jan 11, 2024 at 08:53:46AM +0000, Rodolfo Medina wrote:
> As my machine has a dual boot with MS Windows, F2 and F3 keyboard keys work
> fine in Windows in lowering and increasing sound volume, and F1 for muting it
> etcetera F4, F5, F6..., but in Debian they don't seem to work.

"In Debian" is a wide land :-)

OT1H...

A week ago I installed Debian's Bookworm with MATE on a friend's computer
(Thinkpad x270) and the loudness keys worked out of the box.

OTOH...

Myself -- I have no desktop environment (fvwm on X, *no* systemd, *no*
DBUS, so that would count as "exotic guy").

On my laptop (a Thinkpad x230) the background brightness wasn't working
(I don't know about the loudness things, since I never needed/used them).

Therefore I decided to catch ACPI events and set up this:

--- ---
tomas@trotzki:~$ cat /etc/acpi/events/briteup

event=video/brightnessup
action=/etc/acpi/actions/brite "%e"
--- ---
tomas@trotzki:~$ cat /etc/acpi/events/britedn

event=video/brightnessdown
action=/etc/acpi/actions/brite "%e"
--- ---
tomas@trotzki:~$ cat /etc/acpi/actions/brite 

#!/bin/sh
logger "[ACPI] $@"
BASE="/sys/class/backlight/intel_backlight"
CURR=$(cat "$BASE/brightness")
MAX=$(cat "$BASE/max_brightness")
# MIN is some arbitrary "low" value. Note that for values
# of MIN below 6 (more precisely: 2/11 for our factor), the
# thing gets stuck at the low end: (13 * x) / 11 == x,
# in integer arithmetic, for x <= 5.
#
# The "exponential" algorithm is a bit long at the low
# end. We might consider stretching there. Or increasing
# MIN.

MIN=20
if [ "$CURR" -lt "$MIN" ] ; then CURR="$MIN" ; fi

# NOTE: 11/13 is approx the fourth root of 1/2:
#       i.e. four steps are a doubling/halving
#       of brightness (constant steps gave too
#       coarse jumps in the low range)

case $1 in
  video/brightnessdown* )
    NEW=$(( (11 * CURR) / 13 )) 
    ;;
  video/brightnessup* )
    NEW=$(( (13 * CURR) / 11 )) 
    ;;
  * )
    exit 0
    ;;
esac

if [ "$NEW" -lt "$MIN" ] ; then NEW="$MIN" ; fi
if [ "$NEW" -gt "$MAX" ] ; then NEW="$MAX" ; fi
logger "[ACPI] brightness $CURR --> $NEW"
echo "$NEW" > $BASE/brightness
--- ---

(The charm of using ACPI is that it works independently of X).

To find which events to wait on, just run acpi_listen on a
terminal and hit your dream's key.

> Please help who can, thanks in advance.

The appropriate medication will depend on your microbiome ;-)

Cheers
-- 
t

Attachment: signature.asc
Description: PGP signature


Reply to: