I'm trying to make my linux laptop (a T400 ThinkPad with Libreboot) behave exactly the same way whether the lid is open or closed. To put it another way, I'm trying to simulate a laptop with a broken lid switch that's always in the "lid open" position. I'm looking for a low-level solution that does not require a particular init system or a particular power manager--just software that's expected to be present (or usable) in any GNU/Linux system.
My two OSes are Devuan ASCII (64 bit) and Tiny Core Linux 10.1 (64 bit) running Xorg and fluxbox in case it matters. Kernel versions are 4.16.2 (Devuan) and 4.19.10 (Tiny Core Linux).
I'm using xscreensaver (set to start playing its animations after 1 minute of inactivity) as my test application because I've noticed that xscreensaver does not kick in and start playing animations while the lid is closed. So when I can close the lid, wait just over a minute, re-open the lid, and find that an xscreensaver animation is playing, I'll know that I've found a solution.
WHAT I'VE TRIED SO FAR:
Mechanical. My laptop is a T400 which uses a little magnet above the Bluetooth LED as its lid switch. Putting a tiny refrigerator magnet at that spot causes the lid switch to be stuck in the "closed" position and the xscreensaver test fails. Booting with button.lid_init_state=open kernel boot parameter does not help.
button module boot parameters. This built-in module is the driver for the laptop's lid switch. Using button.lid_report_interval=0 or =-1 or =500000 does not help.
i915 module boot parameters. The kernel in Devuan supports the i915.panel_ignore_lid boot parameter. Setting it to -2 does not help pass the xscreensaver test.
video module boot parameters. Using video.report_key_events=0 does not help.
ACPI. Disabling it with acpi=off kernel boot parameter does not help pass the test.
Disabling the lid switch. Amazingly, disabling the lid switch does not help. It is difficult to disable the button module because it built-in to the kernel (i.e., it shows up with ls /sys/module but not with lsmod). However, it is possible to unbind all the devices that use the button module after the system is booted:
# 1. find the devices that use the button driver: $ ls /sys/bus/acpi/drivers/button LNXPWRBN:00 PNP0C0D:00 PNP0C0E:00 bind uevent unbind # 2. disable the devices one by one: $ echo "LNXPWRBN:00" | sudo tee /sys/bus/acpi/drivers/button/unbind LNXPWRBN:00 $ echo "PNP0C0D:00" | sudo tee /sys/bus/acpi/drivers/button/unbind PNP0C0D:00 $ echo "PNP0C0E:00" | sudo tee /sys/bus/acpi/drivers/button/unbind PNP0C0E:00 # 3. satisfy oneself that the devices are gone: $ ls /sys/bus/acpi/drivers/button bind uevent unbind
Even with this, xscreensaver animations kick in while lid is open but never when lid is closed.
Capturing touchpad events. I noticed by watching the output of cat /dev/input/event5 that opening and closing the laptop lid causes the synaptics touchpad to generate some input. Grabbing all the input with evtest --grab /dev/input/event5 >/dev/null does not help.
Telling X to stay out of the way. I run these commands as regular user at boot after X starts: xset s off; xset -dpms; xset s noblank. The commands tell X that I don't want its blank screen screensaver, that I don't want DPMS, and that it should never blank the screen. It doesn't help.
BIOS. I've searched for ways of disabling the lid switch at the BIOS (Libreboot, in my case) level, but did not find anything relevant.
That's all that I've tried so far. Even with all the above in combination, userland applications (xscreensaver being their representative) still behave differently depending on whether the laptop lid is open or closed. (In the case of xscreensaver, it only starts playing animations when laptop lid is open, never when it is closed.)
Surely there must be a way to completely disable the laptop's lid switch via software, and make userland applications think the laptop lid is always open. What am I missing?