Follow-up on spurious wakeups

So, the fix I implemented for my wakeup problem a few weeks ago had an interesting side effect. Normally, when I put my laptop to sleep, it loses about 10% of its charge per day, which seems reasonable. After my fix, however, it started to lose 40% per day - it's not uncommon for me not to touch my laptop for a few days, so that's not great. So here's a follow-up on how I addressed that issue!

The first step was to verify that it was indeed my change that is causing this - I did some tests to measure battery usage while sleeping (just dumping acpi -b to a terminal every few minutes), and it was indeed the case! As a result of the tests, I discovered that the spurious wakeup problem I fixed only happens when the laptop is plugged in - so really, the problem I'm having is this:

My simple solution to this new problem is to just check if the laptop is plugged in just before suspending - if it is, disable RP13; otherwise, enable it. Now, if it's plugged in, I shut the lid, and then I unplug it, that risks the battery drain problem - but I figured this would be rare enough that I'm fine with the solution.

I wrote a little script to do this:


if acpi -a | grep -q on-line ; then
    if grep enabled /proc/acpi/wakeup | grep -q RP13 ; then
        echo "plugged in and RP13 found - disabling"
        echo RP13 > /proc/acpi/wakeup
    if ! ( grep enabled /proc/acpi/wakeup | grep -q RP13 ) ; then
        echo "on battery and RP13 not found - enabling"
        echo RP13 > /proc/acpi/wakeup

...and I adapted the systemd service I wrote to run that script, and also to be pulled in by rather than so that it runs when the laptop goes to sleep.

Published on 2022-01-12