Tiny Core Linux

Tiny Core Extensions => TCE Corepure64 => Topic started by: GNUser on September 15, 2020, 06:42:39 PM

Title: [Solved] acpid does not recognize Thinkpad's sleep button
Post by: GNUser on September 15, 2020, 06:42:39 PM
I'm running TCL11.1 64-bit on my Thinkpad X200. The  thinkpad-acpi-5.4.3-tinycore64.tcz  extension is loaded. The  acpid.tcz  extension is also loaded.

acpi_listen shows output I press the volume buttons, battery button (Fn + F3) and various other buttons, but shows no output at all when I press the sleep button (Fn + F4):

Code: [Select]
$ sudo /usr/local/etc/init.d/acpid start
$ sudo acpi_listen
button/volumeup VOLUP 00000080 00000000 K
button/volumedown VOLDN 00000080 00000000 K
button/battery BAT 00000080 00000000 K

Is there a special boot code or an additional extension that's required for acpid to recognize the sleep button?
Title: Re: acpid does not recognize Thinkpad's sleep button
Post by: GNUser on September 15, 2020, 07:54:04 PM
Could X or libinput be to blame? xev generates output when battery key (Fn + F3) is pressed, but no output when sleep key (Fn + F4) is pressed:

Code: [Select]
$ xev
---snip---
KeyPress event, serial 36, synthetic NO, window 0x3200001,
    root 0xc8, subw 0x0, time 546887, (54,134), root:(1155,186),
    state 0x0, keycode 244 (keysym 0x1008ff93, XF86Battery), same_screen YES,
    XLookupString gives 0 bytes:
    XmbLookupString gives 0 bytes:
    XFilterEvent returns: False

KeyRelease event, serial 36, synthetic NO, window 0x3200001,
    root 0xc8, subw 0x0, time 546887, (54,134), root:(1155,186),
    state 0x0, keycode 244 (keysym 0x1008ff93, XF86Battery), same_screen YES,
    XLookupString gives 0 bytes:
    XFilterEvent returns: False

I'm running Xorg-7.7.
Title: Re: acpid does not recognize Thinkpad's sleep button
Post by: Sashank999 on September 15, 2020, 08:10:10 PM
I am not familiar with this but from the corebook.pdf, use "laptop" boot code.
Title: Re: acpid does not recognize Thinkpad's sleep button
Post by: tinycorelinux on September 15, 2020, 08:17:55 PM
Hi GNUser!
I've never used an extension like  thinkpad-acpi-5.4.3-tinycore64.tcz, so I can only talk about my method, which may be helpful to you.
You can map the following code to your shortcut keys (for example, Fn + F4) to do the same.
That's what I do. All these functions can be implemented in this way.
Code: [Select]
echo -n mem > /sys/power/state
Title: Re: acpid does not recognize Thinkpad's sleep button
Post by: curaga on September 15, 2020, 11:30:50 PM
Those special buttons are very machine-dependant, try looking at thinkwiki or thinkpad forums how other distros detect that on that specific model.
Title: Re: acpid does not recognize Thinkpad's sleep button
Post by: Sashank999 on September 16, 2020, 02:19:37 AM
This is my way of doing it :
1. Start xev for listening inputs.
2. Press the Fn+F4 and then hit Ctrl+C.
3. Look at the keycode of the pressed key and add it to ~/xinitrc and the command too.
I generally use it to control volume of pulseaudio with External Buttons.
From here
https://wiki.archlinux.org/index.php/Xbindkeys

I think this may work too :
https://wiki.gentoo.org/wiki/ACPI/ThinkPad-special-buttons
.
Title: Re: acpid does not recognize Thinkpad's sleep button
Post by: GNUser on September 16, 2020, 05:41:29 AM
Hello, all. Thanks for your input. The "laptop" boot code did not help. xev shows no output whatsoever when I press Fn+F4 while running TCL.

When I repeat the exercise in my OP in a console, results are the same. This rules out an X or libinput issue.

When I boot into a different OS on same machine, Fn+F4 is detected just fine. So it's not a hardware (defective keyboard/button) issue.

I think the issue is either: a) Fn+F4 keypress is not producing a scancode in TCL or b) kernel's keymap does not have the relevant scancode mapped to the appropriate keycode (KEY_SLEEP). Alas, I'm not sure how to prove or fix either one.

Title: Re: acpid does not recognize Thinkpad's sleep button
Post by: GNUser on September 16, 2020, 06:05:03 AM
I used the  showkey  utility in both Devuan and TCL11.

In Devuan, pressing Fn+F4 produces scancode 0xe0 0xf5 and keycode 142.
In TCL, pressing Fn+F4 produces neither a scancode nor a keycode.

I guess this means the kernel in TCL is not detecting the keypress at all, right? If this can be sorted out, it will take someone more knowledgeable than I am.
Title: Re: acpid does not recognize Thinkpad's sleep button
Post by: GNUser on September 16, 2020, 06:47:32 AM
juanito - I see that the acpid extension for TCL11 is a bit old (version 2.0.23 from 2015). Would you like me to submit an updated extension? You are the maintainer.
Title: Re: acpid does not recognize Thinkpad's sleep button
Post by: Rich on September 16, 2020, 07:50:54 AM
HI GNUser
Do you have a  /proc/acpi/ibm/hotkey  file? Try echoing  0xffffffff  into it as root and see if it generates an event then.

Does this list any  parm:  fields that may be useful:
Code: [Select]
modinfo thinkpad_acpi
Check for differences in Devuan for:
Code: [Select]
lsmod
cat /proc/cmdline

Maybe a search of  sysfs  for  *think*, *hotkey*, or *sleep*  turns up a clue:
Code: [Select]
sudo find /sys -iname *hotkey*
The kernel source tree has Documentation/laptops/thinkpad-acpi.txt. It's a bit dated but may be of use.
Title: Re: acpid does not recognize Thinkpad's sleep button
Post by: GNUser on September 16, 2020, 08:21:00 AM
Hi, Rich. Yes, when the  thinkpad-acpi-KERNEL.tcz  extension is loaded, the file  /proc/acpi/ibm/hotkey  exists. Echoing that value to it does not help things.

modinfo thinkpad_acpi does not hit me over the head with an obviously helpful parameter:
Code: [Select]
TCL11$ modinfo thinkpad_acpi
filename:       /lib/modules/5.4.3-tinycore64/kernel.tclocal/drivers/platform/x86/thinkpad_acpi.ko.gz
author:         Henrique de Moraes Holschuh <hmh@hmh.eng.br>
author:         Borislav Deianov <borislav@users.sf.net>
description:    ThinkPad ACPI Extras
license:        GPL
parm:           fan:Simulates thinkpad-acpi procfs command at module load, see documentation
parm:           volume:Simulates thinkpad-acpi procfs command at module load, see documentation
parm:           brightness:Simulates thinkpad-acpi procfs command at module load, see documentation
parm:           beep:Simulates thinkpad-acpi procfs command at module load, see documentation
parm:           led:Simulates thinkpad-acpi procfs command at module load, see documentation
parm:           cmos:Simulates thinkpad-acpi procfs command at module load, see documentation
parm:           light:Simulates thinkpad-acpi procfs command at module load, see documentation
parm:           video:Simulates thinkpad-acpi procfs command at module load, see documentation
parm:           bluetooth:Simulates thinkpad-acpi procfs command at module load, see documentation
parm:           hotkey:Simulates thinkpad-acpi procfs command at module load, see documentation
parm:           enable:Enable the ALSA interface for the ACPI EC Mixer
parm:           id:ALSA id for the ACPI EC Mixer
parm:           index:ALSA index for the ACPI EC Mixer
parm:           software_mute:Request full software mute control
parm:           volume_control:Enables software override for the console audio control when true
parm:           volume_capabilities:Selects the mixer capabilities: 0=auto, 1=volume and mute, 2=mute only
parm:           volume_mode:Selects volume control strategy: 0=auto, 1=EC, 2=N/A, 3=EC+NVRAM
parm:           brightness_enable:Enables backlight control when 1, disables when 0
parm:           brightness_mode:Selects brightness control strategy: 0=auto, 1=EC, 2=UCMS, 3=EC+NVRAM
parm:           fan_control:Enables setting fan parameters features when true
parm:           force_load:Attempts to load the driver even on a mis-identified ThinkPad when true
parm:           debug:Sets debug level bit-mask
parm:           experimental:Enables experimental features when non-zero
version:        0.26
alias:          dmi:bvnIBM:bvrI[MU]ET??WW*
alias:          tpacpi
alias:          acpi*:LEN0268:*
alias:          acpi*:LEN0068:*
alias:          acpi*:IBM0068:*
srcversion:     244EE1C07B382DED86DB01C
depends:        snd,backlight,video,battery
intree:         Y
vermagic:       5.4.3-tinycore64 SMP mod_unload

Here's some output from my Devuan partition of this same machine:
Code: [Select]
Devuan$ lsmod
Module                  Size  Used by
iptable_filter         16384  0
ip_tables              24576  1 iptable_filter
ip6table_filter        16384  0
ip6_tables             28672  1 ip6table_filter
x_tables               40960  4 ip_tables,iptable_filter,ip6table_filter,ip6_tables
nfsd                  339968  2
auth_rpcgss            61440  1 nfsd
nfs_acl                16384  1 nfsd
nfs                   262144  0
lockd                  98304  2 nfsd,nfs
grace                  16384  2 nfsd,lockd
fscache                65536  1 nfs
sunrpc                339968  6 auth_rpcgss,nfsd,nfs_acl,lockd,nfs
parport_pc             45056  0
ppdev                  20480  0
lp                     20480  0
parport                49152  3 lp,parport_pc,ppdev
arc4                   16384  2
ath9k                 155648  0
ath9k_common           36864  1 ath9k
iTCO_wdt               16384  0
iTCO_vendor_support    16384  1 iTCO_wdt
ath9k_hw              471040  2 ath9k,ath9k_common
coretemp               16384  0
kvm_intel             155648  0
ath                    28672  3 ath9k_hw,ath9k,ath9k_common
mac80211              774144  1 ath9k
kvm                   585728  1 kvm_intel
snd_hda_codec_conexant    24576  1
irqbypass              16384  1 kvm
snd_hda_codec_generic    73728  1 snd_hda_codec_conexant
snd_hda_intel          40960  3
input_leds             16384  0
serio_raw              16384  0
snd_hda_codec         126976  3 snd_hda_intel,snd_hda_codec_conexant,snd_hda_codec_generic
pcspkr                 16384  0
cfg80211              614400  4 mac80211,ath9k,ath,ath9k_common
snd_hda_core           81920  4 snd_hda_intel,snd_hda_codec_conexant,snd_hda_codec,snd_hda_codec_generic
snd_hwdep              16384  1 snd_hda_codec
lpc_ich                24576  0
snd_pcm               102400  3 snd_hda_intel,snd_hda_codec,snd_hda_core
thinkpad_acpi          90112  0
shpchp                 36864  0
snd_timer              32768  1 snd_pcm
nvram                  16384  1 thinkpad_acpi
snd                    81920  14 snd_hda_intel,snd_hwdep,snd_hda_codec_conexant,snd_hda_codec,snd_timer,thinkpad_acpi,snd_hda_codec_generic,snd_pcm
soundcore              16384  1 snd
mac_hid                16384  0
i915                 1671168  3
i2c_algo_bit           16384  1 i915
drm_kms_helper        167936  1 i915
syscopyarea            16384  1 drm_kms_helper
sysfillrect            16384  1 drm_kms_helper
sysimgblt              16384  1 drm_kms_helper
e1000e                241664  0
fb_sys_fops            16384  1 drm_kms_helper
i2c_i801               28672  0
ahci                   36864  3
drm                   397312  5 i915,drm_kms_helper
libahci                32768  1 ahci
psmouse               139264  0
ptp                    20480  1 e1000e
pps_core               20480  1 ptp
video                  40960  2 thinkpad_acpi,i915

Devuan$ cat /proc/cmdline
BOOT_IMAGE=/vmlinuz root=/dev/sda1 quiet

Devuan$ sudo find /sys -iname '*hotkey*'
/sys/devices/platform/thinkpad_acpi/hotkey_recommended_mask
/sys/devices/platform/thinkpad_acpi/hotkey_source_mask
/sys/devices/platform/thinkpad_acpi/hotkey_bios_mask
/sys/devices/platform/thinkpad_acpi/hotkey_enable
/sys/devices/platform/thinkpad_acpi/hotkey_all_mask
/sys/devices/platform/thinkpad_acpi/hotkey_mask
/sys/devices/platform/thinkpad_acpi/hotkey_bios_enabled
/sys/devices/platform/thinkpad_acpi/hotkey_poll_freq
/sys/devices/platform/thinkpad_acpi/hotkey_adaptive_all_mask
/sys/bus/acpi/drivers/thinkpad_hotkey

Devuan$ sudo find /sys -iname '*think*'
/sys/devices/platform/thinkpad_hwmon
/sys/devices/platform/thinkpad_acpi
/sys/devices/platform/thinkpad_acpi/leds/tpacpi::thinkvantage
/sys/class/leds/tpacpi::thinkvantage
/sys/bus/platform/devices/thinkpad_hwmon
/sys/bus/platform/devices/thinkpad_acpi
/sys/bus/platform/drivers/thinkpad_hwmon
/sys/bus/platform/drivers/thinkpad_hwmon/thinkpad_hwmon
/sys/bus/platform/drivers/thinkpad_acpi
/sys/bus/platform/drivers/thinkpad_acpi/thinkpad_acpi
/sys/bus/acpi/drivers/thinkpad_hotkey
/sys/module/nvram/holders/thinkpad_acpi
/sys/module/video/holders/thinkpad_acpi
/sys/module/thinkpad_acpi
/sys/module/thinkpad_acpi/drivers/platform:thinkpad_hwmon
/sys/module/thinkpad_acpi/drivers/platform:thinkpad_acpi
/sys/module/snd/holders/thinkpad_acpi

Devuan$ sudo find /sys -iname '*sleep*'
/sys/kernel/mm/transparent_hugepage/khugepaged/scan_sleep_millisecs
/sys/kernel/mm/transparent_hugepage/khugepaged/alloc_sleep_millisecs
/sys/kernel/mm/ksm/sleep_millisecs
/sys/power/mem_sleep

Devuan$ lsmod
Module                  Size  Used by
iptable_filter         16384  0
ip_tables              24576  1 iptable_filter
ip6table_filter        16384  0
ip6_tables             28672  1 ip6table_filter
x_tables               40960  4 ip_tables,iptable_filter,ip6table_filter,ip6_tables
nfsd                  339968  2
auth_rpcgss            61440  1 nfsd
nfs_acl                16384  1 nfsd
nfs                   262144  0
lockd                  98304  2 nfsd,nfs
grace                  16384  2 nfsd,lockd
fscache                65536  1 nfs
sunrpc                339968  6 auth_rpcgss,nfsd,nfs_acl,lockd,nfs
parport_pc             45056  0
ppdev                  20480  0
lp                     20480  0
parport                49152  3 lp,parport_pc,ppdev
arc4                   16384  2
ath9k                 155648  0
ath9k_common           36864  1 ath9k
iTCO_wdt               16384  0
iTCO_vendor_support    16384  1 iTCO_wdt
ath9k_hw              471040  2 ath9k,ath9k_common
coretemp               16384  0
kvm_intel             155648  0
ath                    28672  3 ath9k_hw,ath9k,ath9k_common
mac80211              774144  1 ath9k
kvm                   585728  1 kvm_intel
snd_hda_codec_conexant    24576  1
irqbypass              16384  1 kvm
snd_hda_codec_generic    73728  1 snd_hda_codec_conexant
snd_hda_intel          40960  3
input_leds             16384  0
serio_raw              16384  0
snd_hda_codec         126976  3 snd_hda_intel,snd_hda_codec_conexant,snd_hda_codec_generic
pcspkr                 16384  0
cfg80211              614400  4 mac80211,ath9k,ath,ath9k_common
snd_hda_core           81920  4 snd_hda_intel,snd_hda_codec_conexant,snd_hda_codec,snd_hda_codec_generic
snd_hwdep              16384  1 snd_hda_codec
lpc_ich                24576  0
snd_pcm               102400  3 snd_hda_intel,snd_hda_codec,snd_hda_core
thinkpad_acpi          90112  0
shpchp                 36864  0
snd_timer              32768  1 snd_pcm
nvram                  16384  1 thinkpad_acpi
snd                    81920  14 snd_hda_intel,snd_hwdep,snd_hda_codec_conexant,snd_hda_codec,snd_timer,thinkpad_acpi,snd_hda_codec_generic,snd_pcm
soundcore              16384  1 snd
mac_hid                16384  0
i915                 1671168  3
i2c_algo_bit           16384  1 i915
drm_kms_helper        167936  1 i915
syscopyarea            16384  1 drm_kms_helper
sysfillrect            16384  1 drm_kms_helper
sysimgblt              16384  1 drm_kms_helper
e1000e                241664  0
fb_sys_fops            16384  1 drm_kms_helper
i2c_i801               28672  0
ahci                   36864  3
drm                   397312  5 i915,drm_kms_helper
libahci                32768  1 ahci
psmouse               139264  0
ptp                    20480  1 e1000e
pps_core               20480  1 ptp
video                  40960  2 thinkpad_acpi,i915

Here's ouput of same commands when running TCL:
Code: [Select]
TCL11$ lsmod
Module                  Size  Used by    Tainted: G 
iptable_mangle         12288  1
iptable_raw            12288  1
xt_connmark            12288  4
nf_conntrack           69632  1 xt_connmark
nf_defrag_ipv4         12288  1 nf_conntrack
xt_mark                12288  2
ip6table_mangle        12288  1
xt_comment             12288  6
xt_addrtype            12288  2
ip6table_raw           12288  1
ip6_tables             24576  2 ip6table_mangle,ip6table_raw
ath9k                  73728  0
mac80211              274432  1 ath9k
ath9k_common           12288  1 ath9k
ath9k_hw              376832  2 ath9k,ath9k_common
ath                    28672  3 ath9k,ath9k_common,ath9k_hw
cfg80211              208896  4 ath9k,mac80211,ath9k_common,ath
cpufreq_userspace      12288  0
cpufreq_powersave      12288  0
cpufreq_conservative    12288  0
wireguard             184320  0
ipv6                  286720 16 ip6table_mangle,wireguard,[permanent]
nf_defrag_ipv6         12288  2 nf_conntrack,ipv6
i915                 1093632  3
thinkpad_acpi          57344  0
i2c_i801               16384  0
snd_hda_codec_conexant    16384  1
snd_hda_codec_generic    45056  1 snd_hda_codec_conexant
snd_hda_intel          24576  0
snd_hda_codec          61440  3 snd_hda_codec_conexant,snd_hda_codec_generic,snd_hda_intel
drm_kms_helper         98304  1 i915
snd_hda_core           36864  4 snd_hda_codec_conexant,snd_hda_codec_generic,snd_hda_intel,snd_hda_codec
snd_hwdep              12288  1 snd_hda_codec
snd_intel_nhlt         12288  1 snd_hda_intel
snd_pcm                57344  3 snd_hda_intel,snd_hda_codec,snd_hda_core
intel_agp              16384  0
snd_timer              24576  1 snd_pcm
drm                   282624  5 i915,drm_kms_helper
snd                    45056  8 thinkpad_acpi,snd_hda_codec_conexant,snd_hda_codec_generic,snd_hda_intel,snd_hda_codec,snd_hwdep,snd_pcm,snd_timer
soundcore              12288  1 snd
intel_gtt              16384  2 i915,intel_agp
agpgart                28672  3 intel_agp,drm,intel_gtt
i2c_algo_bit           12288  1 i915
squashfs               32768 166
zstd_decompress        65536  1 squashfs
battery                16384  1 thinkpad_acpi
ac                     12288  0
video                  32768  2 i915,thinkpad_acpi
backlight              12288  3 i915,thinkpad_acpi,video
xhci_pci               12288  0
xhci_hcd               94208  1 xhci_pci
acpi_cpufreq           12288  1
lpc_ich                20480  0
e1000e                126976  0
loop                   20480 332

TCL11$ cat /proc/cmdline
BOOT_IMAGE=/boot/vmlinuz64 tce=sda3 opt=sda3 tz=EST+5EDT,M3.2.0/2,M11.1.0/2 syslog lang=en_US.UTF-8 user=bruno loglevel=0 host=x200 blacklist=pcspkr

TCL11$ sudo find /sys -iname '*hotkey*'
/sys/devices/platform/thinkpad_acpi/hotkey_bios_mask
/sys/devices/platform/thinkpad_acpi/hotkey_all_mask
/sys/devices/platform/thinkpad_acpi/hotkey_adaptive_all_mask
/sys/devices/platform/thinkpad_acpi/hotkey_mask
/sys/devices/platform/thinkpad_acpi/hotkey_recommended_mask
/sys/devices/platform/thinkpad_acpi/hotkey_source_mask
/sys/devices/platform/thinkpad_acpi/hotkey_bios_enabled
/sys/devices/platform/thinkpad_acpi/hotkey_poll_freq
/sys/devices/platform/thinkpad_acpi/hotkey_enable
/sys/bus/acpi/drivers/thinkpad_hotkey

TCL11$ sudo find /sys -iname '*think*'
/sys/class/leds/tpacpi::thinkvantage
/sys/devices/platform/thinkpad_hwmon
/sys/devices/platform/thinkpad_acpi
/sys/devices/platform/thinkpad_acpi/leds/tpacpi::thinkvantage
/sys/bus/platform/devices/thinkpad_hwmon
/sys/bus/platform/devices/thinkpad_acpi
/sys/bus/platform/drivers/thinkpad_hwmon
/sys/bus/platform/drivers/thinkpad_hwmon/thinkpad_hwmon
/sys/bus/platform/drivers/thinkpad_acpi
/sys/bus/platform/drivers/thinkpad_acpi/thinkpad_acpi
/sys/bus/acpi/drivers/thinkpad_hotkey
/sys/module/battery/holders/thinkpad_acpi
/sys/module/video/holders/thinkpad_acpi
/sys/module/backlight/holders/thinkpad_acpi
/sys/module/thinkpad_acpi
/sys/module/thinkpad_acpi/drivers/platform:thinkpad_acpi
/sys/module/thinkpad_acpi/drivers/platform:thinkpad_hwmon
/sys/module/snd/holders/thinkpad_acpi
bruno@x200:~$ sudo find /sys -iname '*sleep*'
/sys/kernel/mm/transparent_hugepage/khugepaged/scan_sleep_millisecs
/sys/kernel/mm/transparent_hugepage/khugepaged/alloc_sleep_millisecs
/sys/kernel/mm/ksm/sleep_millisecs
/sys/power/mem_sleep
/sys/module/dvb_core/parameters/dvb_powerdown_on_sleep
/sys/module/acpi/parameters/sleep_no_lps0

BTW, the  thinkpad-acpi-KERNEL.tcz  extension does cause some of the special keys (e.g., Fn+F3 which is the battery key) to produce output in  xev  when otherwise there would be no output. So it seems that the  thinkpad-acpi-KERNEL.tcz  extension enables some special keys (e.g., Fn+F3) but not others (e.g., Fn+F4).




Title: Re: acpid does not recognize Thinkpad's sleep button
Post by: GNUser on September 16, 2020, 08:29:41 AM
Hmmm, it seems that in Devuan at least, the  thinkpad_acpi  kernel module is not required for the sleep (Fn+F4) key to be detected.

Notice how in Devuan, even after removing the thinkpad_acpi module, xev can still detect the sleep key when I press it:

Code: [Select]
Devuan$ lsmod | grep think
thinkpad_acpi          90112  0
nvram                  16384  1 thinkpad_acpi
snd                    81920  14 snd_hda_intel,snd_hwdep,snd_hda_codec_conexant,snd_hda_codec,snd_timer,thinkpad_acpi,snd_hda_codec_generic,snd_pcm
video                  40960  2 thinkpad_acpi,i915

Devuan$ sudo modprobe -r thinkpad_acpi
Devuan$ lsmod | grep think
Devuan$ xev
---snip---
KeyPress event, serial 38, synthetic NO, window 0x3600001,
    root 0xb3, subw 0x0, time 49668, (172,89), root:(723,412),
    state 0x0, keycode 150 (keysym 0x1008ff2f, XF86Sleep), same_screen YES,
    XLookupString gives 0 bytes:
    XmbLookupString gives 0 bytes:
    XFilterEvent returns: False


Title: Re: acpid does not recognize Thinkpad's sleep button
Post by: Juanito on September 16, 2020, 08:32:04 AM
Would you like me to submit an updated extension?

Please go ahead.
Title: Re: acpid does not recognize Thinkpad's sleep button
Post by: GNUser on September 16, 2020, 08:57:47 AM
Would you like me to submit an updated extension?

Please go ahead.
Done :)

P.S. The new extension is tested and working. It has more helpful terminal output than the old version. Also, I fixed a hardwired path in acpid.h ("/etc/acpi/events" changed to "/usr/local/etc/acpi/events"). My specific issue persists, of course, because it appears to be due to something missing in the kernel (or one of its modules) that is needed for the sleep key to be recognized at all.
Title: Re: acpid does not recognize Thinkpad's sleep button
Post by: Rich on September 16, 2020, 09:09:18 AM
HI GNUser
Maybe compare the contents of these files:
Code: [Select]
/sys/devices/platform/thinkpad_acpi/hotkey_bios_mask
/sys/devices/platform/thinkpad_acpi/hotkey_all_mask
/sys/devices/platform/thinkpad_acpi/hotkey_adaptive_all_mask
/sys/devices/platform/thinkpad_acpi/hotkey_mask
/sys/devices/platform/thinkpad_acpi/hotkey_recommended_mask
/sys/devices/platform/thinkpad_acpi/hotkey_source_mask
/sys/devices/platform/thinkpad_acpi/hotkey_bios_enabled
/sys/devices/platform/thinkpad_acpi/hotkey_poll_freq
/sys/devices/platform/thinkpad_acpi/hotkey_enable
Title: Re: acpid does not recognize Thinkpad's sleep button
Post by: GNUser on September 16, 2020, 09:42:59 AM
Thanks, Rich. These files are identical across the two systems:

Code: [Select]
TCL:/sys/devices/platform/thinkpad_acpi$ for file in hotkey_bios_mask hotkey_all_mask hotkey_adaptive_all_mask hotkey_mask hotkey_recommended_mask hotkey_source_mask hotkey_bios_enabled hotkey_poll_freq hotkey_enable; do cat $file; done
0x0000080c
0x07ffffff
0x00000000
0x078c7fff
0x078c7fff
0x00000000
0
10
cat: hotkey_enable: Input/output error

Devuan:/sys/devices/platform/thinkpad_acpi$ for file in hotkey_bios_mask hotkey_all_mask hotkey_adaptive_all_mask hotkey_mask hotkey_recommended_mask hotkey_source_mask hotkey_bios_enabled hotkey_poll_freq hotkey_enable; do cat $file; done
0x0000080c
0x07ffffff
0x00000000
0x078c7fff
0x078c7fff
0x00000000
0
10
cat: hotkey_enable: Input/output error

Besides, I don't think the  thinkpad_acpi  module has anything to do with making the sleep key work in Devuan--doing "sudo modprobe -r thinkpad_acpi" causes the entire /sys/devices/platform/thinkpad_acpi directory to disappear but, even after that, pressing the sleep button in Devuan still produces output in xev.
Title: Re: acpid does not recognize Thinkpad's sleep button
Post by: Rich on September 16, 2020, 09:52:22 AM
HI GNUser
... Besides, I don't think the  thinkpad_acpi  module has anything to do with making the sleep key work in Devuan--doing "sudo modprobe -r thinkpad_acpi" causes the entire /sys/devices/platform/thinkpad_acpi directory to disappear but, even after that, pressing the sleep button in Devuan still produces output in xev.
Now don't I feel stupid. I read your post that stated that  thinkpad_acpi  was not needed, then went right ahead and
ask for the contents in the  /sys/devices/platform/thinkpad_acpi  subdirectory. :-[
Title: Re: acpid does not recognize Thinkpad's sleep button
Post by: GNUser on September 16, 2020, 09:54:28 AM
Oh, please don't. I have no idea what to do at this point. Any idea is better than no idea.
Title: Re: acpid does not recognize Thinkpad's sleep button
Post by: GNUser on September 16, 2020, 10:03:05 AM
Strange--it says here that  thinkpad-acpi  is what supports the Fn+F4 key (see the very first table, in the Overview section):
https://www.thinkwiki.org/wiki/How_to_get_special_keys_to_work

Maybe the information is outdated? Whatever the case, in Devuan ASCII support for the Fn+F4 key is clearly coming from elsewhere. Where the support is coming from is the million-dollar question. At this point I have no idea.
Title: Re: acpid does not recognize Thinkpad's sleep button
Post by: jazzbiker on September 16, 2020, 10:24:17 AM
Hi, guys!

Here is citation from showkey man:
"The raw scan codes are available only on AT and PS/2 keyboards, and even then they are disabled unless the atkbd.softraw=0 kernel parameter is used."
At least it seems easy to test...
Title: Re: acpid does not recognize Thinkpad's sleep button
Post by: Rich on September 16, 2020, 10:25:07 AM
HI GNUser
Yeah, I saw that too. The x86 repo has  udev-keymap.tcz  and  xkeyboard-config.tcz.  Does Devuan  have similar
packages installed?

Title: Re: acpid does not recognize Thinkpad's sleep button
Post by: jazzbiker on September 16, 2020, 10:35:16 AM
By the way, what dmesg says about keyboard hardware?
Title: Re: acpid does not recognize Thinkpad's sleep button
Post by: GNUser on September 16, 2020, 10:50:26 AM
Hi, jazzbiker. I repeated the  xev  and  showkey  experiments after booting TCL with the  atkbd.softraw=0  kernel boot paramter. Alas, no difference. Here is what  dmesg  says about my keyboard:
Code: [Select]
TCL$ dmesg | grep keyboard
input: AT Translated Set 2 keyboard as /devices/platform/i8042/serio0/input/input3

Rich, no exact matches among the packages installed on Devuan:
Code: [Select]
Devuan$ apt list --installed | grep -E 'key|map|input|udev|device'

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

debian-archive-keyring/stable,now 2017.5 all [installed]
devuan-keyring/stable,now 2017.10.03 all [installed]
eudev/stable,now 3.2.2-13 amd64 [installed]
gir1.2-gnomekeyring-1.0/stable,now 3.12.0-1+b2 amd64 [installed,automatic]
gir1.2-gudev-1.0/stable,now 230-3 amd64 [installed,automatic]
gnome-keyring/stable,now 3.20.0-3 amd64 [installed]
keyboard-configuration/stable,now 1.164 all [installed]
keyutils/stable,now 1.5.9-9 amd64 [installed,automatic]
libavdevice-dev/stable,now 7:3.2.10-1~deb9u1 amd64 [installed]
libavdevice57/stable,now 7:3.2.10-1~deb9u1 amd64 [installed,automatic]
libchromaprint1/stable,now 1.4.2-1 amd64 [installed,automatic]
libdevmapper1.02.1/stable,now 2:1.02.137-2 amd64 [installed,automatic]
libdmapsharing-3.0-2/stable,now 2.9.37-1 amd64 [installed,automatic]
libeudev-dev/stable,now 3.2.2-13 amd64 [installed,automatic]
libeudev1/stable,now 3.2.2-13 amd64 [installed,automatic]
libgnome-keyring-common/stable,now 3.12.0-1 all [installed,automatic]
libgnome-keyring0/stable,now 3.12.0-1+b2 amd64 [installed,automatic]
libgudev-1.0-0/stable,now 230-3 amd64 [installed,automatic]
libgudev-1.0-dev/stable,now 230-3 amd64 [installed]
libimobiledevice6/stable,now 1.2.0+dfsg-3.1 amd64 [installed,automatic]
libinput-bin/stable,now 1.6.3-1 amd64 [installed,automatic]
libinput10/stable,now 1.6.3-1 amd64 [installed,automatic]
libkeyutils1/stable,now 1.5.9-9 amd64 [installed,automatic]
libnfsidmap2/stable,now 0.25-5.1 amd64 [installed,automatic]
libpam-gnome-keyring/stable,now 3.20.0-3 amd64 [installed,automatic]
libudev-dev/stable,now 1:3.2.2+devuan2.11 amd64 [installed,automatic]
libudev1/stable,now 1:3.2.2+devuan2.11 amd64 [installed]
libwinpr-input0.1/stable,now 1.1.0~git20140921.1.440916e+dfsg1-13+deb9u2 amd64 [installed,automatic]
libxcb-keysyms1/stable,now 0.4.0-1+b2 amd64 [installed,automatic]
nmap/stable,now 7.40-1 amd64 [installed]
python-keyring/stable,now 10.1-1 all [installed,automatic]
python-keyrings.alt/stable,now 1.3-1 all [installed,automatic]
python3-keyring/stable,now 10.1-1 all [installed,automatic]
python3-keyrings.alt/stable,now 1.3-1 all [installed,automatic]
system-config-printer-udev/stable,now 1.5.7-3+b1 amd64 [installed,automatic]
udev/stable,now 1:3.2.2+devuan2.11 amd64 [installed]
x11proto-input-dev/stable,now 2.3.2-1 all [installed,automatic]
xbitmaps/stable,now 1.1.1-2 all [installed,automatic]
xinput/stable,now 1.6.2-1+b1 amd64 [installed]
xserver-xorg-input-all/stable,now 1:7.7+19 amd64 [installed,automatic]
xserver-xorg-input-libinput/stable,now 0.23.0-2 amd64 [installed,automatic]
xserver-xorg-input-synaptics/stable,now 1.9.0-1+b1 amd64 [installed]
xserver-xorg-input-void/stable,now 1:1.4.1-1+b2 amd64 [installed,automatic]
xserver-xorg-input-wacom/stable,now 0.34.0-1 amd64 [installed,automatic]
The xserver-* packages are probably unrelated, since the Fn+F4 key works just fine in console when X is not running.






Title: Re: acpid does not recognize Thinkpad's sleep button
Post by: jazzbiker on September 16, 2020, 11:30:19 AM
The next silly question: have You tried TC 10 or earlier?
Title: Re: acpid does not recognize Thinkpad's sleep button
Post by: GNUser on September 16, 2020, 11:39:55 AM
No, that's a good thought. I just tried TCL10 64bit. Same result as with TCL11: thinkpad-acpi-KERNEL.tcz enables a bunch of the special keys to produce output in  xev  (including the battery key on Fn+F3). However, pressing sleep (Fn+F4) produces no output whatsoever.
Title: Re: acpid does not recognize Thinkpad's sleep button
Post by: jazzbiker on September 16, 2020, 11:46:06 AM
Of course, the existence of dedicated thinkpad-acpi-x.xx.xx-KERNEL modules marks, that some untransparent hardware is lurking in ThinkPads besides i8042. Can we unveil what hardware is driven by this modules? My opinion is, that poor Fn-F4 is eaten by some motherboard habitant.
GNUser, there are no EFI, right? Naked BIOS?
Title: Re: acpid does not recognize Thinkpad's sleep button
Post by: GNUser on September 16, 2020, 11:51:21 AM
No EFI. It's BIOS (well, sort of--I use Libreboot).
Note that no Libreboot-specific adjustments were made to either Devuan or TCL. Therefore, Devuan is detecting Fn+F4 "out of the box".
Title: Re: acpid does not recognize Thinkpad's sleep button
Post by: jazzbiker on September 16, 2020, 11:56:12 AM
Maybe smthg interesting will give
Code: [Select]
dmesg | grep thinkpad ?
Title: Re: acpid does not recognize Thinkpad's sleep button
Post by: GNUser on September 16, 2020, 12:30:23 PM
Wow, some very interesting results:

Code: [Select]
Devuan$ dmesg | grep -i thinkpad
               BIOS vendor: coreboot; Ver: CBET4000 3774c98; Product Version: ThinkPad X200
[    4.275734] thinkpad_acpi: ThinkPad ACPI Extras v0.25
[    4.275736] thinkpad_acpi: http://ibm-acpi.sf.net/
[    4.275737] thinkpad_acpi: ThinkPad BIOS CBET4000 3774c98, EC 7XHT22WW-3.6
[    4.275738] thinkpad_acpi: Lenovo ThinkPad X200, model 7458CU2
[    4.280371] thinkpad_acpi: This ThinkPad has standard ACPI backlight brightness control, supported by the ACPI video driver
[    4.280373] thinkpad_acpi: Disabling thinkpad-acpi brightness events by default...
[    4.285557] thinkpad_acpi: Standard ACPI backlight interface available, not loading native one
[    4.286952] thinkpad_acpi: Console audio control enabled, mode: monitor (read only)
[    4.288999] input: ThinkPad Extra Buttons as /devices/platform/thinkpad_acpi/input/input7
[    7.244446] elogind[2044]: Watching system buttons on /dev/input/event6 (ThinkPad Extra Buttons)

Code: [Select]
TCL$ dmesg | grep -i thinkpad
BIOS vendor: coreboot; Ver: CBET4000 3774c98; Product Version: ThinkPad X200
thinkpad_acpi: ThinkPad ACPI Extras v0.26
thinkpad_acpi: http://ibm-acpi.sf.net/
thinkpad_acpi: ThinkPad BIOS CBET4000 3774c98, EC 7XHT22WW-3.6
thinkpad_acpi: Lenovo ThinkPad X200, model 7458CU2
thinkpad_acpi: This ThinkPad has standard ACPI backlight brightness control, supported by the ACPI video driver
thinkpad_acpi: Disabling thinkpad-acpi brightness events by default...
thinkpad_acpi: Standard ACPI backlight interface available, not loading native one
thinkpad_acpi: Console audio control enabled, mode: monitor (read only)
thinkpad_acpi: battery 1 registered (start 0, stop 0)
battery: new extension: ThinkPad Battery Extension
input: ThinkPad Extra Buttons as /devices/platform/thinkpad_acpi/input/input7

I did a little experiment and killed  elogind  after I was at my desktop in Devuan. Then opened a terminal and watched output of xev. Well, Fn+F3 (among others) consistently produces output, but Fn+F4 produces output only the first time I press it. So maybe elogind has something to do with consistent detection of Fn+F4 on Devuan.

It seems we are no closer to making Fn+F4 work in TCL :-\ Oh, well. Thank you Rich and jazzbiker. If you guys have any more ideas, I'd be happy to try them. But if you are tired of this pesky issue, I understand and would be happy to just let it be.
Title: Re: acpid does not recognize Thinkpad's sleep button
Post by: Rich on September 16, 2020, 12:43:30 PM
HI GNUser
...  but Fn+F4 produces output only the first time I press it. ...
I bet that's related to this:


tc@E310:~$ grep -A 15 'FN+F4' kernel64/linux-4.19.10/Documentation/laptops/thinkpad-acpi.txt 
0x1004  0x03    FN+F4           Sleep button (ACPI sleep button
                                semantics, i.e. sleep-to-RAM).
                                It always generates some kind
                                of event, either the hot key
                                event or an ACPI sleep button
                                event. The firmware may
                                refuse to generate further FN+F4
                                key presses until a S3 or S4 ACPI
                                sleep cycle is performed or some
                                time passes.


Title: Re: acpid does not recognize Thinkpad's sleep button
Post by: GNUser on September 16, 2020, 12: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.
Title: Re: acpid does not recognize Thinkpad's sleep button
Post by: Rich on September 16, 2020, 01: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.
Title: Re: acpid does not recognize Thinkpad's sleep button
Post by: aus9 on September 16, 2020, 06: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
Title: Re: acpid does not recognize Thinkpad's sleep button
Post by: GNUser on September 16, 2020, 08: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).
Title: Re: acpid does not recognize Thinkpad's sleep button
Post by: aus9 on September 16, 2020, 08:43:32 PM
try
Code: [Select]
/dev/input/by-path$ sudo strings  platform-i8042-serio-0-event-kbd
Title: Re: acpid does not recognize Thinkpad's sleep button
Post by: Rich on September 16, 2020, 09:05:29 PM
Hi aus9
That won't change anything. What GNUser posted is exactly what you will see if you look at the raw keyboard output.
Title: Re: acpid does not recognize Thinkpad's sleep button
Post by: GNUser on November 19, 2020, 12: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?

Title: Re: acpid does not recognize Thinkpad's sleep button
Post by: GNUser on November 19, 2020, 12: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
Title: Re: acpid does not recognize Thinkpad's sleep button
Post by: GNUser on November 19, 2020, 04:42:02 PM
Based on Xorg's log it seems that udev removes the Sleep Button device for some reason.
Title: Re: acpid does not recognize Thinkpad's sleep button
Post by: Rich on November 19, 2020, 04: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?
Title: Re: acpid does not recognize Thinkpad's sleep button
Post by: GNUser on November 19, 2020, 09:00:39 PM
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.
Title: Re: acpid does not recognize Thinkpad's sleep button
Post by: Rich on November 19, 2020, 09:20:22 PM
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.
Title: Re: acpid does not recognize Thinkpad's sleep button
Post by: Rich on November 19, 2020, 09:25:20 PM
Hi GNUser
I wonder if  udev-extra.tcz  or  udev-keymap.tcz  might be of some use here.
Title: Re: acpid does not recognize Thinkpad's sleep button
Post by: GNUser on November 20, 2020, 05: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?
Title: Re: acpid does not recognize Thinkpad's sleep button
Post by: GNUser on November 20, 2020, 05: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.
Title: Re: acpid does not recognize Thinkpad's sleep button
Post by: Juanito on November 20, 2020, 05:27:04 AM
It might be something to do with using xf86-input-libinput versus xf86-input-evdev?
Title: Re: acpid does not recognize Thinkpad's sleep button
Post by: Rich on November 20, 2020, 05:36:36 AM
Hi GNUser
I wonder if another application (window manager, gnome, ... ??) is grabbing that key combination for it's own use.
Title: Re: acpid does not recognize Thinkpad's sleep button
Post by: GNUser on November 20, 2020, 05:53:42 AM
I noticed that if I boot with an empty  onboot.lst  then /dev/input/event0 exists.

If I add just these two lines to onboot.lst, then there is no /dev/input/event0 when booting is complete:
Code: [Select]
Xorg-7.7.tcz
xf86-video-intel.tcz

I will try editing Xorg-7.7.tcz.dep so that it pulls in xf86-input-evdev instead of xf86-input-libinput and will report back.
Title: Re: acpid does not recognize Thinkpad's sleep button
Post by: GNUser on November 20, 2020, 06:04:38 AM
Using xf86-input-evdev made no difference. Some other part of the Xorg/video stack is to blame.
Title: Re: acpid does not recognize Thinkpad's sleep button
Post by: Rich on November 20, 2020, 06:05:19 AM
Hi GNUse
I noticed that if I boot with an empty  onboot.lst  then /dev/input/event0 exists. ...
Yes, but is that event tied to the sleep key? Or maybe it's just part of the default root file system included in the  initrd.
If you unpack  rootfs64.gz  or  corepure64.gz  found here:
http://tinycorelinux.net/11.x/x86_64/release/distribution_files/
you will find they contain a pre-populated  /dev  directory.
Title: Re: acpid does not recognize Thinkpad's sleep button
Post by: GNUser on November 20, 2020, 06:26:22 AM
Hi, Rich. Yes, /dev/input/event0 exists when onboot.lst is empty, and catting it shows output when (and only when) sleep button is pressed.
Title: Re: acpid does not recognize Thinkpad's sleep button
Post by: Juanito on November 20, 2020, 07:39:08 AM
I wonder if another application (window manager, gnome, ... ??) is grabbing that key combination for it's own use.

gnome-session automatically invokes sleep after a set period when run on CorePure64, but I can't recall if the sleep button works or not.
Title: Re: acpid does not recognize Thinkpad's sleep button
Post by: GNUser on November 20, 2020, 08:40:44 AM
It wasn't the "base" boot command that was making the problem go away; it was the "norestore" boot command. I had a startup shell script in ~/.X.d/ to disable my Lid Switch. Unfortunately, the script was a bit heavy-handed and was also disabling the Sleep Button with this line:

Code: [Select]
sudo sh -c 'echo PNP0C0E:00 >/sys/bus/acpi/drivers/button/unbind'
Commenting-out that line made all the problems go away. Please forgive me for the noise. I'm so embarrassed...  :-[

Thread may be marked as "Solved".
Title: Re: acpid does not recognize Thinkpad's sleep button
Post by: GNUser on November 20, 2020, 08:53:26 AM
So it turns out that no extensions are needed for the Sleep Button to be detected on my X200 ThinkPad (neither acpid.tcz nor acpitool.tcz nor thinkpad-acpi-KERNEL.tcz).

udev detects the button at boot and creates /dev/input/eventX (in my case, /dev/input/event0). After that, Xorg automatically detects the button as an xinput device (both "cat /var/log/Xorg.0.log" and "xinput --list" confirm this). It is curious that a single button is treated as its own separate input device, but the udev/Xorg creators must have had their reasons.

Now all I have to do is to bind  XF86Sleep  to some action. I use  sxhkd.tcz  to manage my keyboard shortcuts, so will associate  XF86Sleep  with sudo sh -c "echo mem >/sys/power/state" in  ~/.config/sxhkd/sxhkdrc  and all will be well :)

And the Sleep Button (Fn+F4) lived happily ever after.
Title: Re: [Solved] acpid does not recognize Thinkpad's sleep button
Post by: Rich on November 20, 2020, 09:12:59 AM
Hi GNUse
I wonder if another application (window manager, gnome, ... ??) is grabbing that key combination for it's own use.
So in a way I was right, except it wasn't an application grabbing the key, it was your script. ;D
Title: Re: [Solved] acpid does not recognize Thinkpad's sleep button
Post by: GNUser on November 20, 2020, 09:35:36 AM
Yes, absolutely. It was your comment that caused me to scrutinize my startup applications and scripts. As always, thank you very much! Your resourcefulness has helped me get on the right track (after going around in circles) time and again.