This isn’t a general solution, each laptop is going to have a different USB layout. You’d have to run lsusb.py to list out the devices, find the address for the keyboard and replace “1-4.3” in the command for the keyboard address.
Also, this command is only for the session so you’d have to rerun it every time you boot the laptop. My main problem is the touchpad waking the laptop during sleep, and this only fixes the keyboard so I’m just waiting for the bios fix at this point
Yet another failed wake up here (not whining, just keeping track of how often it happens).
@Clay_Rosenthal By “this issue”, do you mean your laptop waking up while in your backpack or do you mean your laptop not waking up? This topic mentions both issues but was (and apparently remains) primarily about the former.
Any updates? My laptop wakes up in my bag EVERY TIME so I just shut it down every time I have to carry it somewhere. We need a UEFI update ASAP to address this issue so the keyboard is disabled when the lid is closed.
1 Like
Doing no tasks, even in suspend mode, my FW16 still gets hot.
It must be doing something in order to convert energy to heat, whether that is charging the battery, doing updates while “sleeping” (apparently a windows thing).
As a cheesy workaround, drop this script into /lib/systemd/system-sleep/20-disable-wakeup.sh and make it executable by root:
#!/bin/bash
shopt -s nullglob
case $1 in
pre)
systemctl stop bluetooth
for d in /sys/bus/usb/devices/*/power/wakeup /sys/bus/i2c/devices/*/power/wakeup; do
echo disabled > "$d"
done
;;
post)
systemctl start bluetooth;;
esac
That will disable wakeup by all USB and i2c devices as well as disable bluetooth (which I have seen cause weird hangs during the suspend process).
You can then test it by running systemctl suspend, waiting for the laptop to sleep, and then do touchpad and keyboard stuff. It should stay asleep until you close/reopen the lid or hit the power button.
3 Likes
Thanks, very helpful! Though I’d like to be able to wake up the laptop via keyboard, just not when the lid is closed. But I don’t presume we have access to the lid state in Linux, right?
Lid state is somewhere in /proc/acpi/button – on my system, it is at
/proc/acpi/button/lid/LID0/state. It will probably be the same for all systems.
Modifying my cheesy little script to account for lid state and multiple keyboards is left as an exercise for the reader – when I have an external keyboard it runs thru a USB 3.2 dock that provides system power as well, and my patterns always have the lid open when I am using the system – if the lid is closed, I want the system to be asleep.
Yes. I want it to sleep too when the lid is closed. But when the lid is open and the system is in suspend, that’s a mode where I want to be able to use the keyboard to wake up the system. I’ll post a script here once I get it to work.
I applaud you, just tested the script and does exactly what I need. Of course not a permanent solution, but it can do the job until a new BIOS patch rolls along.
Interesting. It has now been 24 days (and counting) since my last freeze-on-resume, i.e. we are getting close to a situation where the laptop just works ©.
The two noticeable changes in my habits are:
- suspending less often (but still suspending and resuming at least once per day)
- turning bluetooth off (bluetoothd is running but
bluetoothctl show | grep Power
returns Powered: no PowerState: off-blocked
)
On Fedora 40, my laptop is also waking from sleep in my backpack. I have confirmed this several times by hearing the beep of a connection being made on my bluetooth headphones within about a minute of shutting the laptop lid and putting it in my backpack. They disconnect automatically upon shutting the lid, so I know that it is suspending at least initially.
3 Likes
The fact that there hasn’t been a UEFI update to fix this is frankly mind-boggling to me.
5 Likes
By the way, this issue also exists with the Framework 13 AMD, at least for the touchpad (at least my machine doesn’t wake from sleep by pressing a keyboard key, but it does from pressing the touchpad), and there too it can be activated by the lid/display when the laptop is closed.
Anyone else finding this topic when searching for the issue with their Framework 13 AMD, see Laptop powered off, battery empty after 3 days - #11 by Daniel_Gibson for a workaround (tell Linux not to wake from touchpad events)
1 Like
It has been quite some time since I last reported my experience in this thread.
Good news: since I applied “the two noticeable changes in my habits” (cf my previous message), my Framework 16 laptop successfully wakes up from s2idle sleep every time.
Of course, it is also possible that something was fixed by a kernel update (the laptop runs Debian Sid).
Bad news: I experienced the lid-hitting-the-keyboard-or-touchpad issue multiple times, both at home when the cat walks on the laptop (cat-proofing is the next step after dog-fooding) and when traveling. Regarding the latter, system logs confirm the laptop typically wakes up when I start walking. Depending on how long I walk and what is running on my laptop, it may or may not be burning hot when I finally take it out of my bagpack.
I intend to investigate whether I can configure the exact kind of events that wake up my system so as to work around that issue, but a firmware update that ignores all Framework input modules when the lid is closed would make sense.
2 Likes
Modifying my cheesy little script to account for lid state and multiple keyboards is left as an exercise for the reader
The script below targets USB and i2c devices so as to disable wakeup only for devices known to sit under the lid – the regex can probably be further adjusted to account for devices I do not own.
#!/usr/bin/env bash
state='disabled'
# Framework keyboard and numpad should not wake the laptop:
grep -l 'Framework' /sys/bus/usb/devices/*/manufacturer |\
sed 's/manufacturer$/product/' |\
xargs grep -lP 'Laptop 16 (Keyboard|Numpad) Module' |\
sed 's/product$//' |\
while read -r framework_keyboard_device;
do
echo "${state}" > "${framework_keyboard_device}/power/wakeup"
done
# The PixArt touchpad should not wake the laptop:
for pixart_device in /sys/bus/i2c/devices/i2c-PIXA*; do
echo "${state}" > "${pixart_device}/power/wakeup"
done
2 Likes
Here’s a systemd unit to run that script on boot for those wanting to quickly add it to their system:
[Unit]
Description=Prevents keyboard and trackpad from waking machine while lid is closed by calling /etc/disable-wakeup.sh
[Service]
Type=oneshot
ExecStart=/etc/disable-wakeup.sh
[Install]
WantedBy=multi-user.target
To add it, copy the above unit file and run:
sudoedit /etc/systemd/system/disable-wakeup.service
Paste the text. Save and exit your editor.
Copy Xavier’s script and run:
sudoedit /etc/disable-wakeup.sh
Paste the text. Save and exit your editor.
Then run these commands to “install” the new service:
sudo chmod a+x /etc/disable-wakeup.sh
sudo systemctl daemon-reload
sudo systemctl enable --now disable-wakeup.service
1 Like
@Peter_J_Stewart: nice – although, on my side, I simply dropped my script in /usr/lib/systemd/system-sleep/20-disable-wakeup.sh, as hinted by @Victor_Lowther. It seems there is no documented /etc counterpart to that /usr directory.
Additionally, since we are discussing scripts and workaround, here is my cat-proof
script for Linux+X.org: it runs unprivileged but requires the DISPLAY environment to be set. Otherly put, it must be launched as part of the X session (possibly via XDG autostart). It polls the lid state and enables/disables all input devices underneath accordingly. That way, my cat can walk on the laptop without inputting anything.
#!/usr/bin/env bash
DEVICES=(
'Framework Laptop 16 Keyboard Module - ANSI Keyboard'
'Framework Laptop 16 Numpad Module Keyboard'
'keyboard:Framework Laptop 16 Numpad Module Consumer Control'
'PIXA3854:00 093A:0274 Mouse'
'PIXA3854:00 093A:0274 Touchpad'
)
script_name=$(basename "$0")
device_id_file="/tmp/${script_name}.ids"
if [ ! -f "${device_id_file}" ]; then
for device in "${DEVICES[@]}"; do
xinput list --id-only "${device}"
done > "${device_id_file}"
fi
current_state=''
known_state=''
function get_state {
[[ "$(</proc/acpi/button/lid/LID0/state)" =~ open ]] && current_state='open' || current_state='closed'
}
function state_changed {
[ "${known_state}" == 'open' ] && action='enable' || action='disable'
adjust_devices "${action}"
}
function adjust_devices {
local action="$1"
xargs -n 1 xinput "${action}" < "${device_id_file}"
}
function update_state {
get_state
if [ "${current_state}" != "${known_state}" ]; then
known_state="${current_state}"
state_changed
fi
}
function watch_state {
while sleep 5; do
update_state
done
}
if [ "$1" ]; then
adjust_devices "${1}"
exit
fi
watch_state
Damn. My FW16 failed to wake up from suspend again.
I noticed it was not entirely bricked though:
- the power button was still blinking
- upon removal of the touchpad, the small LED on the right side of the laptop started blinking red-blue-off, red-blue-off – presumably, the firmware was still reacting to that kind of events.
At this stage, I am running Debian Sid’s 6.10.12 kernel.