This is a guide for laptops having issues with suspend under linux. This is not solving suspend issues but it's a way of reducing energy consumption when closing the lid.
For the background, I am running Zorin OS 18 on a MacBook pro Mid 2017 (MacBookPro14,1) and sleep doesn't work properly for my laptop under linux. Basically my laptop can go to sleep but then doesn't come back properly.
The issue seems to be related to the Apple's NVMe controller and the fact that it is all proprietary. This is a know problem for the 2016 and 2017 Macbooks Pro under linux: GitHub - Dunedan/mbp-2016-linux: State of Linux on the MacBook Pro 2016 & 2017
The best workaround I have found is to use a custom script using acpid (acpid - ArchWiki) which can turn off network, switch gnome to power save mode, use pm-utils to add extra power saving tools and pause running applications when closing the laptop lid.
This is how I have done it:
1) Change Lid Close Behavior
The first step is to disable suspend when closing the laptop lid, see here: Change Lid Close Behavior in Ubuntu 24.04 | 22.04 | 20.04 | UbuntuHandbook
2) Make sure you have "screen blank" set
This is so that the screen turn off after few minutes, I have set it to 2min.
3) Install pm-utils and acpid
sudo apt install pm-utils acpid
4) create lid.sh script
mkdir -p /etc/acpi/
sudo vi /etc/acpi/lid.sh
5) Paste the following inside the script and save
This will on closing lid:
- set Gnome profile to power-save
- enable pm-utils powersave
- Turn off networks
- Stop some processes that use some resources like pipewire, webkitwebProcess, gnome-software, tracker-miner and nautilus
Then revert everything when opening the lid.
Paste the following inside the script and save
#/bin/sh
# When closing the lid
grep -q close /proc/acpi/button/lid/*/state
if [ $? = 0 ]; then
# set power profile to power-saver
powerprofilesctl set power-saver
# Turn on pm-utils powersave
sudo pm-powersave true
# Turn off networks
nmcli networking off
# Stop running applications
pkill -STOP pulseaudio
pkill -STOP pipewire
pkill -STOP pipewire-pulse
pkill -f -STOP WebKitWebProcess
pkill -STOP gnome-software
pkill -f -STOP tracker-miner-fs-3
pkill -STOP nautilus
fi
# When opening the lid
grep -q open /proc/acpi/button/lid/*/state
if [ $? = 0 ]; then
# set power profile to balanced
powerprofilesctl set balanced
# turn off pm-utils powersave off
sudo pm-powersave false
# Turn networks on
nmcli networking on
# Restart applications
pkill -CONT pulseaudio
pkill -CONT pipewire
pkill -CONT pipewire-pulse
pkill -f -CONT WebKitWebProcess
pkill -CONT gnome-software
pkill -f -CONT tracker-miner-fs-3
pkill -CONT nautilus
fi
You can add more applications in the list depending on what you usually run on your laptop, e.g: brave, firefox, thunderbird,... You can get application name with the top command and monitor which applications are using a lot of energy.
6) Make the script executable
sudo chmod +x /etc/acpi/lid.sh
7) create lm_lid file
sudo mkdir -p /etc/acpi/events/
sudo vi /etc/acpi/events/lm_lid
8) Paste the following code inside the lm_lid file and save
event=button/lid.*
action=/etc/acpi/lid.sh
9) Restart acpi service or reboot laptop
sudo service acpid restart
Finally, if you want to see if this small script makes a difference, you can open a terminal and run this script which will give you an energy consumption estimation
sudo turbostat --Summary --quiet --show PkgWatt --interval 60
In my case I go from around 3.52 PkgWatt during normal usage to 1.51 PkgWatt when my lid is closed and the script has run.
Any feedback would be appreciated. Also, if you know any other processes that could be paused when the lid is closed without affecting the system, please let me know.