Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.
/ thinkpad_acpi Public archive

A script to disable the lap mode sensor on thinkpads. Patches the thinkpad_acpi kernel module automatically using dkms.

License

Notifications You must be signed in to change notification settings

JosiahBull/thinkpad_acpi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⚠️ I no longer have a laptop with this acceleration sensor so can't reasonably maintain this repository, it has been archived. Be warned that there have been mixed results on newer kernals. ⚠️

Linux Thinkpad Disable Lapmode

During the purchase of a recent ThinkPad, I ran into an issue where I was forced to stay on the "balanced" power-mode. This is because some ThinkPads have a small accelerometer which detects if it's on an unstable surface (e.g. a lap).

Ostensibly this is because some of these devices can get dangerously hot on the bottom during use, but personally I prefer to have control over my device and what power-mode I'm in.

This script works by downloading thinkpad_acpi from the linux kernel, compiling it, and then patching the existing kernel module.

Am I affected?

In gnome power settings you might see this:

screenshot of an output demonstrating lapmode enabled

Or, you may see this result from running the powerprofilectl command:

$ powerprofilesctl
  performance:
    Driver:     platform_profile
    Inhibited:  yes (lap-detected)

* balanced:
    Driver:     platform_profile

  power-saver:
    Driver:     platform_profile

Will this solution work for me?

Some thinkpads don't seem to respect the changes, they may have some other kernel/hardware level control, I'm not sure what causes this.

Supported Operating Systems

These are distros I have actually tested the script on.

  • Fedora 34/35/36
  • Ubuntu 20.04/22.04
  • Manjaro Linux 18 (Illyria)

Installation

You are replacing a kernel module, this comes with some degree of risk to your system. Please consider backing up important data before beginning.

Install prerequisites

# RHEL (F34+)
sudo dnf update
sudo dnf install make automake gcc gcc-c++ kernel-devel dkms wget openssl

# Ubuntu (20.04+)
sudo apt-get update && sudo apt-get upgrade
sudo apt-get install build-essential dkms git

# Arch Linux/Manjaro
sudo pacman -Syu
sudo pacman -S base-devel dkms git wget openssl linux-headers
# You might need to install other linux-headers according to your kernel version

# Reboot after updates!
sudo reboot

Install module

git clone https://github.com/JosiahBull/thinkpad_acpi
cd thinkpad_acpi

# Copy the files for dkms
sudo cp -R . /usr/src/thinkpad_acpi-1.0

# Add the module to dkms
sudo dkms add -m thinkpad_acpi/1.0

# Build the module
# !!!IMPORTANT!!! An internet connection is required for this step! A script will automatically download
# and patch files from the linux kernel. See scripts/download.sh for more information.
sudo dkms build thinkpad_acpi/1.0

# Install the module
sudo dkms install thinkpad_acpi/1.0

# Reboot to reload the kernel
sudo reboot

Upon running sudo modinfo thinkpad_acpi, you should see the version is set to:

version: 420.26
singer: DKMS module signing key

Congratulations! You've patched your kernel. The lap-mode sensor is now disabled.

Uninstallation

Uninstallation is easy, dkms should restore the original kernel module.

sudo dkms uninstall thinkpad_acpi/1.0
sudo dkms remove thinkpad_acpi/1.0
yes | sudo rm -rd /usr/src/thinkpad_acpi-1.0
sudo reboot

Other Solutions

# This is a guess for possible syntax, I provide no guarantees.
probe module("thinkpad_acpi").function("lapsensor_get").return {
    *present = 1;
    *state = 1;
}

Relevant Discussions

Licensing & Contribution

All contributions are welcome, and will be licensed under MIT unless otherwise specified.

About

A script to disable the lap mode sensor on thinkpads. Patches the thinkpad_acpi kernel module automatically using dkms.

Topics

Resources

License

Stars

Watchers

Forks

Contributors 4

  •  
  •  
  •  
  •