Fix laptop waking up while lid is closed and heating up

Write tutorials for Linux Mint here
More tutorials on https://github.com/orgs/linuxmint/discu ... /tutorials and (archive) on https://community.linuxmint.com/tutorial
Forum rules
Don't add support questions to tutorials; start your own topic in the appropriate sub-forum instead. Before you post read forum rules
Post Reply
thebestlettuce
Level 1
Level 1
Posts: 7
Joined: Thu Nov 30, 2023 2:41 pm

Fix laptop waking up while lid is closed and heating up

Post by thebestlettuce »

I had this problem for a while where my laptop would start to heat up while closed, and realized its because it was being woken up while closed and running when it should be suspended. I managed to figure out it was because my bluetooth mouse was giving it input while rattlign around in my backpack and waking it up.

You can diagnose this by closing your laptop almost fully so that the screen shuts off but you can still see it. Move your mouse around and if your screen turns on you have your problem

This script uses an ACPI event for the screen closing to fix this issue. This is made for the ASUS Zenbook 14 but will probably work with minor changes to other laptops

Follow the instructions at the top to set it up

(i only kind of know what im doing so lmk if this doesnt work for you)

Code: Select all

#!/bin/bash

#┌────────────────────────────────────────┐
#│Solves the problem of laptop waking     │
#│up while suspended due to getting input │
#│from the mouse                          │
#│                                        │
#│Needs to be set up with ACPI to start   │
#│when the lid closes                     │
#│                                        │
#│Should not run while the laptop is in   │
#│use, only when the lid is closed        │
#│                                        │
#│v1.1                                    │
#└────────────────────────────────────────┘

#┌────────────────────────────────────────────────────┐
#│To set up, add the following to                     │
#│/etc/acpi/events/lid-close-mouse-disable            │
#│                                                    │
#│ event=button/lid.*                                 │
#│ action=/etc/acpi/lid-close-mouse-disable.sh %e     │
#│                                                    │
#│Then, put this script in                            │
#│/etc/acpi/lid-close-mouse-disable.sh                │
#│                                                    │
#│There are some more variables you have to set below │
#└────────────────────────────────────────────────────┘

# run xinput list
# then, find your mouse id and put it here
# possibly when you plug in more devices this changes
device=9

# use whereis to make sure these paths are right
cat=/usr/bin/cat
grep=/usr/bin/grep
xinput=/usr/bin/xinput
systemctl=/usr/bin/systemctl
sleep=/usr/bin/sleep

# path that stores the state of your lid
# might say LID instead of LID0 or some other path entirely
# script depends on this file containing "open" when open
lidstate=/proc/acpi/button/lid/LID0/state

# run env | grep Xauthority
# put that value here
export XAUTHORITY=/home/probably-your-name-here/.Xauthority

#====== do not edit after here ======#

# xinput needs these
export DISPLAY=:0

# this script runs when a close event or an open event
# no need to do anything for an open event
echo $1 | grep open
if [ $? -eq 0 ]; then
	exit
fi

while :; do
	$cat $lidstate | $grep open
	if [ $? -ne 0 ]; then
		# lid closed
		$xinput disable $device
		$systemctl suspend
	else
		# lid open
		$xinput enable $device
		exit
	fi
	$sleep 1
done

User avatar
BG405
Level 9
Level 9
Posts: 2510
Joined: Fri Mar 11, 2016 3:09 pm
Location: England

Re: Fix laptop waking up while lid is closed and heating up

Post by BG405 »

This contribution is appreciated. Often I suspend and forget to hit the switch on the mouse straight away and the machine wakes up again.
Dell Inspiron 1525 - LM17.3 CE 64-------------------Lenovo T440 - Manjaro KDE with Mint VMs
Toshiba NB250 - Manjaro KDE------------------------Acer Aspire One D255E - LM21.3 Xfce
Acer Aspire E11 ES1-111M - LM18.2 KDE 64 ----Two ROMS don't make a WRITE
Post Reply

Return to “Tutorials”