WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: how to completely disable lid switch?  (Read 14465 times)

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11705
Re: how to completely disable lid switch?
« Reply #15 on: November 13, 2019, 03:18:23 PM »
Hi GNUser
Does your machine report anything for:
Code: [Select]
cat /sys/module/button/parameters/lid_report_intervalIf it does, try setting it to  0  or  -1.

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1530
Re: how to completely disable lid switch?
« Reply #16 on: November 13, 2019, 03:25:16 PM »
Thank you, Rich.
My laptop reports 500.
I cannot set it to -1 ("Invalid argument"). I can set it to 0, but it does not seem to help (xscreensaver still refuses to kick in while lid is closed) :(
« Last Edit: November 13, 2019, 03:36:16 PM by GNUser »

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1530
Re: how to completely disable lid switch?
« Reply #17 on: November 13, 2019, 03:42:18 PM »
I set it to 500000 to see what would happen. xscreensaver still refuses to kick in when lid is closed.

I have to say this is the most stubborn issue I've ever had with GNU/Linux. It's usually a very malleable OS.

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1530
Re: how to completely disable lid switch?
« Reply #18 on: November 13, 2019, 03:52:16 PM »
I found /proc/acpi/button/lid/LID/state which does seem to consistently accurately report the lid switch state. Getting warmer?

Code: [Select]
$ cat /proc/acpi/button/lid/LID/state
state: open
$ sleep 5; cat /proc/acpi/button/lid/LID/state # I close the lid after entering the command
state: closed
$ echo 0 | sudo tee /sys/module/button/parameters/lid_report_interval
$ sleep 5; cat /proc/acpi/button/lid/LID/state # I close the lid after entering the command
state: closed
$ echo 500000 | sudo tee /sys/module/button/parameters/lid_report_interval
$ sleep 5; cat /proc/acpi/button/lid/LID/state # I close the lid after entering the command
state: closed
$ sudo acpitool -W 17 # this disables the lid switch wakeup device
$ cat /proc/acpi/button/lid/LID/state
state: open
$ sleep 5; cat /proc/acpi/button/lid/LID/state # I close the lid after entering the command
state: closed

Bottomline from all the above: No matter what I do, I cannot disable the lid switch--but at least the output of cat /proc/acpi/button/lid/LID/state is always accurate with regard to whether the lid is open or closed.

Maybe there's a way to force the file to always say open? (Alas, I wouldn't expect chattr +i to work on the /proc virtual filesystem.)
« Last Edit: November 13, 2019, 04:07:29 PM by GNUser »

Offline jazzbiker

  • Hero Member
  • *****
  • Posts: 934
Re: how to completely disable lid switch?
« Reply #19 on: November 14, 2019, 01:09:45 AM »
Hi, GNUser!

Sorry again for my silly posts, but so much time spent struggling with this lid switch was enough to compile custom lid-less kernel. If you hate this lid switches, solve the problem once and forever.

Thanks for Your answers.

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1530
Re: how to completely disable lid switch?
« Reply #20 on: November 14, 2019, 05:59:43 AM »
A last attempt before recompiling kernel: Finding a way to disable the button kernel module.

I took a look at the kernel's source code, and the module that enables the lid switch is called button
https://github.com/torvalds/linux/blob/master/drivers/acpi/button.c

button does not show up in output of lsmod or find /lib/modules/4.19.10-tiny
core64/kernel/ -name 'button.ko.gz'
but does show up in output of ls /sys/module, so it's loaded and must be a kernel builtin. Therefore, it cannot be blacklisted with blacklist=<module_name> kernel boot parameter.

However, it seems there is a way to disable built-in kernel modules: initcall_blacklist=<module's_initialization_function>. I can't find a function in button.c that has the __init attribute, so I tried blacklisting various functions in button.c that have _init in the name, to no avail.

Can someone help me figure out which initcall I should blacklist in order to prevent the button kernel module from being loaded (or some other way to disable that module short of recompiling kernel)? I realize it would probably disable both my lid switch and power button, but that's fine--I only use the power button to power on, never to poweroff.
« Last Edit: November 14, 2019, 06:18:52 AM by GNUser »

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11705
Re: how to completely disable lid switch?
« Reply #21 on: November 14, 2019, 08:53:31 AM »
Hi GNUser
Try:
Code: [Select]
initcall_blacklist=acpi_button_register_driver

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1530
Re: how to completely disable lid switch?
« Reply #22 on: November 14, 2019, 09:21:27 AM »
Thank you, Rich, but no joy. The module still gets loaded.

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14851
Re: how to completely disable lid switch?
« Reply #23 on: November 14, 2019, 09:36:19 AM »
Maybe you could use the acpid extension and write a rule to achieve what you wish to happen when the lid is closed?

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1530
Re: how to completely disable lid switch?
« Reply #24 on: November 14, 2019, 09:50:44 AM »
acpid would be a great tool if I were looking to do something special when the kernel reports that the lid is closed.
However, what I want is for the kernel to never report to userland that the lid is closed--for it to either always report it as open or else ignore it completely.
« Last Edit: November 14, 2019, 09:53:46 AM by GNUser »

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11705
Re: how to completely disable lid switch?
« Reply #25 on: November 14, 2019, 09:58:49 AM »
Hi GNUser
Thank you, Rich, but no joy. The module still gets loaded.
Did  dmesg  log any output in response to the blacklist request?

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1530
Re: how to completely disable lid switch?
« Reply #26 on: November 14, 2019, 10:14:14 AM »
Hmm, it did, but it doesn't look good:

Code: [Select]
$ dmesg | grep blacklist
Command line: BOOT_IMAGE=/boot/vmlinuz64 tce=sda2/tce opt=sda2 blacklist=pcspkr blacklist=uvcvideo tz=EST+5EDT,M3.2.0/2,M11.1.0/2 syslog lang=en_US.UTF-8 user=bruno initcall_blacklist=acpi_button_register_driver
Kernel command line: BOOT_IMAGE=/boot/vmlinuz64 tce=sda2/tce opt=sda2 blacklist=pcspkr blacklist=uvcvideo tz=EST+5EDT,M3.2.0/2,M11.1.0/2 syslog lang=en_US.UTF-8 user=bruno initcall_blacklist=acpi_button_register_driver
initcall_blacklist requires CONFIG_KALLSYMS

It seems that Pure64's kernel was compiled without the configuration option needed for initcall_blacklist to work. Darn.

-----

It the meantime, I tried my old trick of taping a magnet over the lid switch (my T400's lid switch is actually a little magnet above the bluetooth LED). However, doing this results in the switch always being in the "closed" state. I tried the boot parameter button.lid_init_state=open but it makes no difference--the magnet causes constant "closed" state.

-----

It seems I'm running out of options. I'll ask on the kernel mailing list just to make sure we aren't missing something.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11705
Re: how to completely disable lid switch?
« Reply #27 on: November 14, 2019, 10:26:18 AM »
Hi GNUser
... It the meantime, I tried my old trick of taping a magnet over the lid switch (my T400's lid switch is actually a little magnet above the bluetooth LED). However, doing this results in the switch always being in the "closed" state. I tried the boot parameter button.lid_init_state=open but it makes no difference--the magnet causes constant "closed" state. ...
You could try weakening/dispersing the magnetic field by placing something metallic between the lid magnet and the switch. Maybe
several layers of aluminum foil or a piece of sheet steel (top of a tuna can).
« Last Edit: November 14, 2019, 10:28:20 AM by Rich »

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1530
Re: how to completely disable lid switch?
« Reply #28 on: November 14, 2019, 11:00:21 AM »
Excellent idea! I'll try that, or some magnetic insulation tape if it doesn't work.

Either way, I'll stop bothering you guys with this miniscule issue. If I hear something helpful back from the kernel guys, I'll share it.

Cheers,
gnuser


Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11705
Re: how to completely disable lid switch?
« Reply #29 on: November 14, 2019, 11:08:51 AM »
Hi GNUser
... I'll stop bothering you guys with this miniscule issue. ...
No bother. It allowed me to spend some quality time looking through the  /proc  and  /sys  file systems as well as driver code. :)