WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: [Solved] acpid does not recognize Thinkpad's sleep button  (Read 16685 times)

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1530
Re: acpid does not recognize Thinkpad's sleep button
« Reply #30 on: September 16, 2020, 03:57:25 PM »
I can confirm that without elogind running in Devuan, first press of sleep key produces output in xev, then no output for (what feels like) a long while, then it produces output one more time followed by no output for a while... Exactly as described in that quote. Nice find, Rich!!

So it seems that   elogind  does not get involved in generating an event when the sleep button is pressed--it simply notices the event and puts the machine to sleep.

So it's still a mystery what exactly is generating an event when sleep key is pressed. Because the quote describes so accurately what's going on, it suggests thinkpad-acpi is what generates the event. But there are two problems with that theory: 1) Devuan can generate events without thinkpad_acpi being loaded and 2) TCL10 64bit and TCL11 bit (the two versions I've tested) cannot produce an event despite thinkpad_acpi being loaded.

There must be something more to the story.

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11703
Re: acpid does not recognize Thinkpad's sleep button
« Reply #31 on: September 16, 2020, 04:07:11 PM »
HI GNUser
Does your keyboard show up in  /dev/input/by-id/ ? If it does, try catting that keyboard file and see if it responds to FN+F4.

aus9

  • Guest
Re: acpid does not recognize Thinkpad's sleep button
« Reply #32 on: September 16, 2020, 09:09:10 PM »
In addition to above,

1) Have you confirmed you do not need firmware or if need, its ok?

2) Have you considered modding an app I found in devuan,

http://www.nongnu.org/tpb/doc/tpb.1.html

known keys it interacts with are
Code: [Select]
IDENTIFIER        STATES/VALUE
thinkpad          pressed
home              pressed
search            pressed
mail              pressed
favorites         pressed
reload            pressed
abort             pressed
backward          pressed
forward           pressed
fn                pressed
zoom              on, off
thinklight        on, off
display           lcd, crt, both
expand            on, off
brightness        PERCENT
volume            PERCENT
mute              on, off
ac_power          connected, disconnected
powermgt_ac       high, auto, manual
powermgt_battery  high, auto, manual

    [EDIT]: Added code tags.  Rich
« Last Edit: September 16, 2020, 10:06:43 PM by Rich »

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1530
Re: acpid does not recognize Thinkpad's sleep button
« Reply #33 on: September 16, 2020, 11:29:32 PM »
Hi, Rich. I don't have /dev/input/by-id but I do have /dev/input/by-path. When I cat the keyboard file, I see output when I press various keys (see below) but I see no output with any of the special Fn+F? keys.

Code: [Select]
TCL:/dev/input/by-path$ sudo cat platform-i8042-serio-0-event-kbd
Õb_(ö9Õb_(ö9Õb_(ö Õb_ï9Õb_ï9Õb_ïÕb_be9Õb_be9Õb_be Õb_kÜ9Õb_kÜ9Õb_kÜÕb_ Ø=Õb_ Ø=Õb_ ØÕb_=Õb_=Õb_Õb_1
=Õb_1
=Õb_1
Õb_Â
    =Õb_Â
         =Õb_Â
               Õb_= Õb_= Õb_ Õb_1= Õb_1= Õb_1¬Õb_S×®¬Õb_S×r¬Õb_S×­Õb_إ®­Õb_إr­Õb_إ­Õb_jÛ
                                                                                        °­Õb_jÛ
                                                                                               s­Õb_jÛ

Hi, aus9. Thanks for the input (pun intended). I have never needed to install firmware for the Thinkpad keyboard in the past when using other OSes (Devuan, Arch Linux). I do not have the  tpb  utility installed in Devuan but I see that it's available in the repository. I'll give it a shot, but the information here (http://www.thinkwiki.org/wiki/How_to_get_special_keys_to_work) confirms your impression that this utility is useful for many special buttons but not for the button I need (the sleep button on Fn+F4).

aus9

  • Guest
Re: acpid does not recognize Thinkpad's sleep button
« Reply #34 on: September 16, 2020, 11:43:32 PM »
try
Code: [Select]
/dev/input/by-path$ sudo strings  platform-i8042-serio-0-event-kbd
« Last Edit: September 16, 2020, 11:52:17 PM by aus9 »

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11703
Re: acpid does not recognize Thinkpad's sleep button
« Reply #35 on: September 17, 2020, 12:05:29 AM »
Hi aus9
That won't change anything. What GNUser posted is exactly what you will see if you look at the raw keyboard output.

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1530
Re: acpid does not recognize Thinkpad's sleep button
« Reply #36 on: November 19, 2020, 03:20:27 PM »
I made some progress with this. In Devuan, I cat'ed all events in /dev/input/ to see which one produced output when I pressed Fn+F4.

I found that 'cat /dev/input/event0' produces output when I press Fn+F4. Interestingly, no other mouse or keyboard activity causes output from event0.

So I tried to figure out what this event0 refers to:

Code: [Select]
Devuan$ dmesg | grep event0
[    7.148279] elogind[2005]: Watching system buttons on /dev/input/event0 (Sleep Button)

Code: [Select]
Devuan$ grep event0 /var/log/Xorg.0.log
[     9.236] (II) config/udev: Adding input device Sleep Button (/dev/input/event0)
[     9.237] (**) Option "Device" "/dev/input/event0"
[     9.238] (II) input device 'Sleep Button', /dev/input/event0 is tagged by udev as: Keyboard
[     9.238] (II) input device 'Sleep Button', /dev/input/event0 is a keyboard
[     9.260] (**) Option "config_info" "udev:/sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:2a/PNP0C09:00/PNP0C0E:00/input/input0/event0"
[     9.262] (II) input device 'Sleep Button', /dev/input/event0 is tagged by udev as: Keyboard
[     9.262] (II) input device 'Sleep Button', /dev/input/event0 is a keyboard

Wow, so it seems that the Sleep Button is an input device all by itself!

Does the above suggest a way for TCL11 x86_64 to be able similarly add the Sleep Button as an input device?


Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1530
Re: acpid does not recognize Thinkpad's sleep button
« Reply #37 on: November 19, 2020, 03:25:54 PM »
On TCL, it seems that the kernel detects the Sleep Button. It seems that Xorg detects it as well. However, /dev/input/event0 does not actually exist:

Code: [Select]
TCL$ dmesg | grep -i Sleep
input: Sleep Button as /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:2a/PNP0C09:00/PNP0C0E:00/input/input0
ACPI: Sleep Button [SLPB]

TCL$ grep -i Sleep /var/log/Xorg.0.log
[    25.326] (II) config/udev: Adding input device Sleep Button (/dev/input/event0)
[    25.326] (**) Sleep Button: Applying InputClass "libinput keyboard catchall"
[    25.326] (II) Using input driver 'libinput' for 'Sleep Button'
[    25.326] (**) Sleep Button: always reports core events
[    25.327] (II) event0  - Sleep Button: is tagged by udev as: Keyboard
[    25.327] (II) event0  - Sleep Button: device is a keyboard
[    25.327] (II) event0  - Sleep Button: device removed
[    25.386] (II) XINPUT: Adding extended input device "Sleep Button" (type: KEYBOARD, id 8)
[    25.390] (II) event0  - Sleep Button: is tagged by udev as: Keyboard
[    25.390] (II) event0  - Sleep Button: device is a keyboard
[    25.566] (II) event0  - Sleep Button: device removed
[    25.909] (II) config/udev: Adding input device Sleep Button (/dev/input/event0)
[    25.909] (**) Sleep Button: Applying InputClass "libinput keyboard catchall"
[    25.909] (II) Using input driver 'libinput' for 'Sleep Button'
[    25.909] (**) Sleep Button: always reports core events
[    25.911] (II) event0  - Sleep Button: is tagged by udev as: Keyboard
[    25.911] (II) event0  - Sleep Button: device is a keyboard
[    25.911] (II) event0  - Sleep Button: device removed
[    25.973] (II) event0  - Sleep Button: is tagged by udev as: Keyboard
[    25.973] (II) event0  - Sleep Button: device is a keyboard
[    26.573] (II) config/udev: removing device Sleep Button
[    26.573] (II) event0  - Sleep Button: device removed

TCL# cd /dev/input
TCL# ls
by-path/ event3   event5   event7   event9   mouse0
event2   event4   event6   event8   mice     ts0

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1530
Re: acpid does not recognize Thinkpad's sleep button
« Reply #38 on: November 19, 2020, 07:42:02 PM »
Based on Xorg's log it seems that udev removes the Sleep Button device for some reason.

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11703
Re: acpid does not recognize Thinkpad's sleep button
« Reply #39 on: November 19, 2020, 07:57:01 PM »
Hi GNUser
Have you tried running this in Devuan:
Code: [Select]
xmodmap -pke > Devuan.txtThen compare the results to this in TC:
Code: [Select]
xmodmap -pke > TC.txtto see if it's an issue with how the keyboard is programmed?
« Last Edit: November 19, 2020, 08:06:46 PM by Rich »

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1530
Re: acpid does not recognize Thinkpad's sleep button
« Reply #40 on: November 20, 2020, 12:00:39 AM »
Hi, Rich. The relevant part of the two files (Devuan.txt and TC.txt) is identical:

Code: [Select]
keycode 150 = XF86Sleep NoSymbol XF86Sleep
keycode 151 = XF86WakeUp NoSymbol XF86WakeUp

It seems that udev is the culprit here. Early in the boot process the kernel detects the sleep button (see dmesg output above) as does Xorg (see Xorg.log.0 contents above), but then udev seems to think the sleep button gets "removed". As a consequence, /dev/input/event0 disappears.

Here is another difference between Devuan and TCL (which would be expected given udev's naughty behavior in TCL). Notice the lack of "Sleep Button" in TCL:

Code: [Select]
Devuan$ xinput --list
⎡ Virtual core pointer                    id=2 [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer              id=4 [slave  pointer  (2)]
⎜   ↳ TPPS/2 IBM TrackPoint                    id=10 [slave  pointer  (2)]
⎣ Virtual core keyboard                    id=3 [master keyboard (2)]
    ↳ Virtual core XTEST keyboard              id=5 [slave  keyboard (3)]
    ↳ Power Button                            id=6 [slave  keyboard (3)]
    ↳ Video Bus                                id=7 [slave  keyboard (3)]
    ↳ Sleep Button                            id=8 [slave  keyboard (3)]
    ↳ AT Translated Set 2 keyboard            id=9 [slave  keyboard (3)]
    ↳ ThinkPad Extra Buttons                  id=11 [slave  keyboard (3)]

Code: [Select]
TCL$ $ xinput --list
⎡ Virtual core pointer                    id=2 [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer              id=4 [slave  pointer  (2)]
⎜   ↳ TPPS/2 IBM TrackPoint                    id=10 [slave  pointer  (2)]
⎣ Virtual core keyboard                    id=3 [master keyboard (2)]
    ↳ Virtual core XTEST keyboard              id=5 [slave  keyboard (3)]
    ↳ Power Button                            id=6 [slave  keyboard (3)]
    ↳ Video Bus                                id=7 [slave  keyboard (3)]
    ↳ AT Translated Set 2 keyboard            id=9 [slave  keyboard (3)]
    ↳ ThinkPad Extra Buttons                  id=11 [slave  keyboard (3)]

I don't know much about how udev works, so I'm stuck for now.

P.S. The unresponsive sleep button in TCL is not a big deal at all. It's the mysterious nature of the problem that bothers me.
« Last Edit: November 20, 2020, 12:09:29 AM by GNUser »

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11703
Re: acpid does not recognize Thinkpad's sleep button
« Reply #41 on: November 20, 2020, 12:20:22 AM »
Hi GNUser
... Here is another difference between Devuan and TCL (which would be expected given udev's naughty behavior in TCL). Notice the lack of "Sleep Button" in TCL: ...
Yet xinput picked it up in TCL:
Quote
Code: [Select]
[    25.386] (II) XINPUT: Adding extended input device "Sleep Button" (type: KEYBOARD, id 8)
right down to the same id number.

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11703
Re: acpid does not recognize Thinkpad's sleep button
« Reply #42 on: November 20, 2020, 12:25:20 AM »
Hi GNUser
I wonder if  udev-extra.tcz  or  udev-keymap.tcz  might be of some use here.

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1530
Re: acpid does not recognize Thinkpad's sleep button
« Reply #43 on: November 20, 2020, 08:05:22 AM »
Loading  udev-extra.tcz  at boot via  onboot.lst  did not help.

The repo for TCL11 x86_64 does not have  udev-keymap.tcz  , so I installed the one available in the x86 repo. Loading it at boot via onboot.lst did not help.

There seems to be something unique about the Sleep Button device: Notice how the last line here stands out from the rest:
Code: [Select]
TCL$ grep -i config/udev /var/log/Xorg.0.log
[    25.656] (II) config/udev: Adding input device Power Button (/dev/input/event2)
[    25.697] (II) config/udev: Adding input device Video Bus (/dev/input/event4)
[    25.748] (II) config/udev: Adding input device Lid Switch (/dev/input/event1)
[    25.749] (II) config/udev: Adding input device Sleep Button (/dev/input/event0)
[    25.800] (II) config/udev: Adding input device HDA Intel Headphone (/dev/input/event9)
[    25.800] (II) config/udev: Adding input device HDA Intel Mic (/dev/input/event6)
[    25.801] (II) config/udev: Adding input device HDA Intel Dock Mic (/dev/input/event7)
[    25.801] (II) config/udev: Adding input device HDA Intel Dock Headphone (/dev/input/event8)
[    25.802] (II) config/udev: Adding input device AT Translated Set 2 keyboard (/dev/input/event3)
[    25.865] (II) config/udev: Adding input device TPPS/2 IBM TrackPoint (/dev/input/event5)
[    25.926] (II) config/udev: Adding input device TPPS/2 IBM TrackPoint (/dev/input/mouse0)
[    25.927] (II) config/udev: Adding input device ThinkPad Extra Buttons (/dev/input/event10)
[    26.324] (II) config/udev: Adding input device Power Button (/dev/input/event2)
[    26.357] (II) config/udev: Adding input device Video Bus (/dev/input/event4)
[    26.408] (II) config/udev: Adding input device Lid Switch (/dev/input/event1)
[    26.409] (II) config/udev: Adding input device Sleep Button (/dev/input/event0)
[    26.463] (II) config/udev: Adding input device HDA Intel Headphone (/dev/input/event9)
[    26.463] (II) config/udev: Adding input device HDA Intel Mic (/dev/input/event6)
[    26.464] (II) config/udev: Adding input device HDA Intel Dock Mic (/dev/input/event7)
[    26.464] (II) config/udev: Adding input device HDA Intel Dock Headphone (/dev/input/event8)
[    26.465] (II) config/udev: Adding input device AT Translated Set 2 keyboard (/dev/input/event3)
[    26.508] (II) config/udev: Adding input device TPPS/2 IBM TrackPoint (/dev/input/event5)
[    26.569] (II) config/udev: Adding input device TPPS/2 IBM TrackPoint (/dev/input/mouse0)
[    26.571] (II) config/udev: Adding input device ThinkPad Extra Buttons (/dev/input/event10)
[    27.077] (II) config/udev: removing device Sleep Button

And notice the absence of  event0  here:
Code: [Select]
TCL$ ls /dev/input
by-path/ event2   event4   event6   event8   mice     ts0
event10  event3   event5   event7   event9   mouse0

Maybe X's log is misleading and X is actually to blame for this, not udev?

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1530
Re: acpid does not recognize Thinkpad's sleep button
« Reply #44 on: November 20, 2020, 08:14:03 AM »
If I boot with "base norestore" boot codes, then  /dev/input/event0  exists and "cat /dev/input/event0" shows some output when I press the Sleep Button (Fn+F4).

This seems to support the idea that udev is innocent and something else (e.g., X) may be to blame.