News for hackers. Stuff that matters.
Re:Why does Linux have so much trouble sleeping and waking? by MarkusWandel on Friday December 11, 2020 @01:39PM (#25389048)
I run a number of Linux laptops ranging from 10 to 3 years old (i.e. nothing bleeding edge) and except for one long retired ancient one, and one in current use, suspend/resume has been flawless (hibernate not so much; if the kids leave one unplugged and it auto-hibernate as the battery runs low, it seems about 50/50 success whether it emerges from hibernation in a usable state).

Now what is not flawless: There are any number of ACPI things that, if set, will immediately re-wake the computer once suspended. The following script is on my current problematic one as /usr/lib/systemd/system-sleep/wakefix.pl

#!/usr/bin/perl open(FILE,"/proc/acpi/wakeup"); while(<FILE>) { chomp; if(/enabled/) { ($a,$b) = split / /; system("echo $a >/proc/acpi/wakeup"); } }

[Sorry about the mangled formatting]

It just turns off everything that is enabled to wake the machine up. As this list happens not to include the power button - the only thing I want to be able to wake the laptop up - this works fine.

I've never experimented with auto-suspend on lid close and auto-resume on open; maybe that's what's more troublesome.

Another thing that's not suspend-resume, but nonetheless annoying - if the machine is running an SDL fullscreen thing (Tuxpaint) or if the MATE desktop has a pop-up menu open, the power button won't suspend the computer, because something intercepts the button press.

My experience with suspend/resume on Desktop machines has been 100% bad, on the other hand. Usually they suspend just fine, but don't resume to a usable state.

Re:Why does Linux have so much trouble sleeping and waking? by chadlavi on Friday December 11, 2020 @02:52PM (#25390065)
> I've never experimented with auto-suspend on lid close and auto-resume on open; maybe that's what's more troublesome.

That's what 99% of all laptop users would like a laptop be able to do, no? At the very least auto-suspend on close.

Re:Why does Linux have so much trouble sleeping and waking? by MarkusWandel on Friday December 11, 2020 @04:09PM (#25391013)
Auto-suspend on lid close is a feature that I hate. Even on my work Windows laptop, I can never be sure that it will suspend, and half the time you wish it wouldn't because then your VPN connection will time out, etc. Thus people walking around with their laptop open a couple of inches. Much better to completely disable auto-suspend and get used to just pushing the suspend button and waiting the couple of seconds for it to react and then closing the lid.

That's the main reason I can't even be bothered to configure this (as in from the GUI) on my Linux machines.

Re:Why does Linux have so much trouble sleeping and waking? by hsitz on Friday December 11, 2020 @04:53PM (#25391685)
I understand that. My Linux machine is a 2015 Asus UX305 laptop. Suspend/resume works under Ubuntu's desktop, but I use i3wm, which requires the user to enable features like that themselves. I never did get auto-suspend to work, but I was able to get suspend to work when I attached to a hotkey. So instead of closing lid (or having auto-suspend after, say, 30 minutes inactivity), I just press the hotkey to have the machine suspend. I grew to prefer this to lid-closing. (Auto-resume always worked fine under i3wm, just press any key and it started up).
Re:Why does Linux have so much trouble sleeping and waking? by javier2 on Saturday December 12, 2020 @04:47PM (#25402034)
The Asus UX3xx series has been working near flawless for me. I now have a ryzen based matebook that is quite moody wrt to suspend. I havent used hibernate in over 10 years.
Re:Why does Linux have so much trouble sleeping and waking? by MarkusWandel on Friday December 11, 2020 @04:11PM (#25391042)
And what I mean by "flawless" is that the machine can be suspended and unsuspended hundreds of times between reboots, and that suspend/resume are quick. This definition of "flawless" also applies to the laptop that has the workaround on it. Kiddie laptops in this household aren't the most modern ones and reboots require patience.
Re:Why does Linux have so much trouble sleeping and waking? by chadlavi on Friday December 11, 2020 @11:05PM (#25395417)
As a Mac user this is pure madness to me.
Re:Why does Linux have so much trouble sleeping and waking? by ACow_Adonis on Friday December 11, 2020 @03:23PM (#25390481)
maybe that's the issue: as a hacker/ programmer/ data scientist, I spend my life trying to get the computer to not sleep/ suspend when I walk away because it's generally doing something.

My use case is in direct contrast to the 99%, and with Linux being focused on a technical audience, it gets short shrift in terms of priorities/ resources.

(honestly, most of my computers are generally set to no automatic sleeping/ suspension)

Re:Why does Linux have so much trouble sleeping and waking? by BHSPitMonkey on Friday December 11, 2020 @03:34PM (#25390608)
I can't remember how many times in the last few years I've shut/stowed my ThinkPad, commuted home, and opened my backpack to find it burning hot and drained of battery because it either failed to sleep on close or reawakened itself while put away.

Even now, turning off or disconnecting my Bluetooth headphones causes my modern/up-to-date Linux machines to reawake if they were connected before sleep, which inevitably causes my monitors to come back online and fill my room with light and fan noise while I'm trying to put _myself_ to sleep...

Re:Why does Linux have so much trouble sleeping and waking? by freedomben on Friday December 11, 2020 @03:43PM (#25390706)
Me too. I happens just often enough that I get complacent and forget to check D-:

I have a habit now of just running:

    systemctl suspend -i
Before closing the lid. Wake ups always work. That will suspend even if some applications is blocking suspends.
Re:Why does Linux have so much trouble sleeping and waking? by core-questions on Friday December 11, 2020 @04:42PM (#25391464)
> opened my backpack to find it burning hot

Right? It's like, trying to suffocate itself. I just turn the damned thing off before going home now.

Re:Why does Linux have so much trouble sleeping and waking? by IfOnlyYouKnew on Friday December 11, 2020 @03:45PM (#25390749)
This comment is baffling...

If I get it right, it's saying that Linux is intentionally bad at shutdown / hibernation because that's how its users want it. And users want it because they are better users than other users: they are "professionals", whose computers never sleep.

So, if you are using an OS that actually works as expected, that's just proof that you're an amateur.

(and let's ignore the mention of the lid being closed. Because that would be devastating to this argument)

Re:Why does Linux have so much trouble sleeping and waking? by ACow_Adonis on Saturday December 12, 2020 @06:03AM (#25397475)
I didn't say Linux is intentionally bad at hibernation/shutdown: I said maybe it's not a priority in terms of resources/focus.

At no point did I say users want it to be bad at shutdown/hibernation.

I said for my job/use-case, I spend most of my time trying to stop the computer from sleeping. I posted this because the comment I was responding to said that 99% of users wanted the computer to sleep on lid-shut, and I thought I'd contribute to point out that's the opposite of my use case (indeed, I pretty much want the computer to never sleep on lid-shut). And i run linux as the primary OS on pretty much all my computers. A lot of linux users are also probably coming from a background where computers didn't sleep/shutdown very often.

I didn't use the word amateur. I didn't use the word professional. I didn't mention anything about using an OS that works as expected. I listed my background and use case.

I didn't say anything about any users being better than others.

I do think, based on all that, you may have some sensitivities that made you interpret things in a particular light.

Re:Why does Linux have so much trouble sleeping and waking? by chadlavi on Friday December 11, 2020 @03:33PM (#25390601)
> auto-suspend on lid close

on lid close being the operative term here.

Re:Why does Linux have so much trouble sleeping and waking? by cactus2093 on Friday December 11, 2020 @03:31PM (#25390574)
No offense to you, but if this isn't the most Linux user's answer I've ever read...

The first line seems to disagree that there's any issue, says it has been "flawless". Then goes on to list what I would certainly consider some very big flaws which can only be partially worked around with custom shell scripts and the like.

Re:Why does Linux have so much trouble sleeping and waking? by mulmen on Friday December 11, 2020 @03:39PM (#25390664)
GP said several laptops were flawless but one of them was problematic and required the custom scripts.
Re:Why does Linux have so much trouble sleeping and waking? by rektide on Friday December 11, 2020 @02:24PM (#25389636)
Your experiences matches my own closely. My desktop machines have done as well though!

Suspend/resume to memory and to disk have been exceedingly reliable on every machine I've touched for a decade for me. On my old Dell convertible laptop, the wifi would only turn on every other time it woke up.

The machines waking up is a real problem. I have `HandleLidSwitch=ignore` in systemd's logind.conf[1]. I see there are other options though, which I might also try setting to ignore. I too sometimes have unexpected wakeups. I'd like to learn more about how to debug these. I've asked twice on IRC & gotten no reply. My backup plan has been to write a daemon to make the system go to sleep, and whenever it wakes up, put it back to sleep, unless I "disarm" the daemon. I'm in a fairly low-visibility environment now though- I feel like I should work the problem some, fix whatever is going wrong, rather than hack around, but I have not been successful at figuring out second steps in debugging systemd daemons, once `systemd status` & upping the logging level falls short.

I too have problems with some desktop things intercepting my power button, which again, I wish I had better visibility in to. I don't know other than trial & error to figure out who might be grabbing the input devices.

[1] https://www.freedesktop.org/software/systemd/man/logind.conf....

Re:Why does Linux have so much trouble sleeping and waking? by dmd on Friday December 11, 2020 @02:56PM (#25390131)
> Usually they suspend just fine, but don't resume to a usable state.

Kind of like cryonics then?

Re:Why does Linux have so much trouble sleeping and waking? by breakfastduck on Friday December 11, 2020 @03:43PM (#25390717)
Auto suspend on lid close / open is probably the most important feature I can imagine on a laptop.

And people actually expect Linux to win over the desktop crowd when it can’t support even the most basic features consumers expect.

Re:Why does Linux have so much trouble sleeping and waking? by tluyben2 on Friday December 11, 2020 @03:06PM (#25390262)
I use x220s (2011) for just about anything and everything is flawless with them. Including auto suspend on lid close and resume on open. Same experience on a few newer Dell laptops I was gifted ( will look up the types in the morning if anyone cares; I do not like the keyboards vs the x220 so I do not use them much ). I run the latest Ubuntu with i3 and my own scripts (which I have been tweaking over the years) to fix battery life etc. What machines did you try?