XPS 13 9370 wakes from sleep randomly?

Iā€™ve been using Ubuntu Mate 18.04 LTS on my 9370 (Developer Edition) for a weeks now, and almost everything works perfectly, except sleep.

The computer appears to go to sleep, (hard to tell, since the front LED doesnā€™t ā€œbreatheā€ like youā€™d expect a laptop LED to do), and sometimes will go to sleep, other times does not, and sometimes wakes itself up randomly. This naturally causes excessive battery drain, and Iā€™ve run the battery flat twice in the past week because of it.

Anyone else running into this same issue, and/or know of a solution/anything to check for misconfiguration?

I have ran into this back in Ubuntu 12.04, and understand how frustrating it can be.

Finding info on how to solve the issue can be even more frustrating because, thanks to the shakeups induced by the adoption of systemd, a lot of the older info is out of date, and the some of the solutions suggested may not work.

Here is a links that should get you started:

The basic strategy is to list the devices which could be causing spurious wakeup events with:

cat /proc/acpi/wakeup

Then you can try the method listed in the link above to toggle the events state to disabled by echoing itā€™s name 4 letter abbreviation to /proc/acpi/wakeup.

The 4 letter codes you are echoing are abbreviations based on your specific hardware, for example on my laptop LID0 is the lid switch, and PWRB is the power button. I would stay away from disabling these since that could put you in a canā€™t-wake-from-sleep condition, but others should be fair game to temporarily disable.

For example:

echo EUS1 | sudo tee /proc/acpi/wakeup

Would disable the EUS1 event. Then you can suspend and see if it stays asleep without issues, and wakes properly with the power button or lid switch.

This may help identify which wakeup event is causing the issue, but toggling the state of the event to disabled is not persistent, so when you reboot, the issue will return.

This prompted suggestions to place the fix into your /etc/rc.local startup script - which may fix the not-persistent-on-reboot issue, but apparently STILL may not be a complete fix on some hardware because the problem may return after the first sleep/wake event.

To get around this you can create a runs on wakeup type script, or try the ā€œsystemd solutionā€ shown in the last post in the thread linked above.

I know this is a bit complicated, so if you have any questions, just start by running:

cat /proc/acpi/wakeup

ā€¦ and copying and pasting the results from the terminal, and weā€™ll take it from there.

Iā€™ve had this on my Toshiba Satellite running 16.04 LTS but only for the last few months!

I have been assuming it was a hardware problem (the lid does not latch, only closes more or less neatly, and Iā€™m beginning to think putting a heavy weight on the lid helps) but now Iā€™ll look at the possibility itā€™s a software issue.

Well, I feel like Alice all of a suddenā€¦

Thank you for the direction to ACPI wakeups Crotchety, I wasnā€™t aware they existed.

Around the time that my XPS started doing this, my other laptops decided it would be a good idea to do the same. One (other than the XPS) is loaded with Mate, (an Asus), the other with Antergos (Lenovo Thinkpad).

This led me down the rabbit hole of /etc/tmpfiles.d (who named this one, BTW?), and I was all set to make that ANOTHER etc folder that I symlink into my own git-versioned configuration repo, except, when it rains, it pours, of course they each have different default enabled wakeups.

I wrote the following script to run through Ansible on each of the machines to programmatically write the configuration file for each machine:

#!/bin/bash

# This script attempts to programmactically determine which ACPI wakeups are enabled,
# and write a tmpfiles.d unit file to disable them.

WAKEUPS=/etc/tmpfiles.d/acpi-wakeups.conf
WAKEUPS_DIR=$(dirname "$WAKEUPS")

# Create the /etc/tmpfiles.d directory if it does not exist
if [ ! -d $WAKEUPS_DIR ]
then
    mkdir $WAKEUPS_DIR
fi

# Remove the wakeups file if it already exists from manual insertion
if [ -e $WAKEUPS ]
then
    rm $WAKEUPS
fi

for i in `cat /proc/acpi/wakeup|grep "*enabled"|awk '{print $1}'|grep -v -e LID -e PBTN -e SLPB`
do
    echo "w /proc/acpi/wakeup - - - - "$i >> $WAKEUPS
done

Nice try :smile:

importante: /proc/acpi/wakeup is being depricated, you should look into this.

You can write directly to wakeup without a seperate script.

awk '/enabled/{if ($1 !~ /PBTN|LID|SLPB/) print $1}' /proc/acpi/wakeup > /proc/acpi/wakeup

Edit: and that did not work :angry:, this does but its sloppy:

for i in `/usr/bin/awk '/enabled/{if ($1 !~ /PBTN|LID|SLPB/) print $1}' /proc/acpi/wakeup`;do echo $i|tee /proc/acpi/wakeup;done

Good luck!

And take a look at this,

That certainly does flip the bits, and I think your systemd unit file is probably a better solution than my shell script. I just havenā€™t learned the systemd syntax yet, and you have witnessed the extent of my awk knowledge. :grinning:

I would be curious to know what /proc/acpi/wakeup is being replaced with, though.

I donā€™t know, i havenā€™t read up about it yet :smile:

Great you like the script, i had similar problems with machines waking up for no apparent reason. So after i looked into it i saw all these events like mouse clicks, key-presses and USB-inserts waking the system up. REEEEally annoying to battery life :anger_right:

Keep the posts coming, we need them :grin: