BLU Discuss list archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Discuss] Suspend is Great…When it Sticks
- Subject: [Discuss] Suspend is Great…When it Sticks
- From: kentborg at borg.org (Kent Borg)
- Date: Tue, 19 Nov 2024 18:18:53 -0500
My current Linux computer, like the one before it, isn't very good at staying asleep. Configuring it to sleep when the lid closes does work, but it is the event of *closing* the lid that does it, not the static state of *being* closed. And it seems something or other can wake it. While the lid is still closed. No one is closing the lid (it is closed, in my carry on, under the seat in front of me), so there is no event to trigger another suspend. So I wrote a trivial little (Rust) program: "sleep-dammit". It looks at the lid state and if closed, it tells systemd to suspend, and it does that in an infinite loop. The loop also has a 10-second thread sleep, so a bug won't put my in an aggressively narcoleptic battle. It prints a time stamped message saying it is suspending. And when the lid is open it also prints a time stamped message, but only every 60 times through the loop. Mostly I don't want the computer to sleep when the lid is closed, so I expect I mostly won't run this program. But when I do grab it as I go out and about, I can choose run sleep-dammit. No, I didn't write some fancy stateful program that does cool stuff over D-bus. Someone already did that, and it doesn't work. So I wrote something really simple and manual: If the program is running and the lid is closed, suspend. Today I was out on some errands and I carried my computer with me, as a test. This is the output I saw when I got back home: > lid open at Tue Nov 19 17:36:44 2024. > lid closed, but if we hit this code we are running, so suspend at Tue > Nov 19 17:38:14 2024. > lid closed, but if we hit this code we are running, so suspend at Tue > Nov 19 17:57:03 2024. > lid closed, but if we hit this code we are running, so suspend at Tue > Nov 19 18:24:45 2024. > lid closed, but if we hit this code we are running, so suspend at Tue > Nov 19 18:50:54 2024. > lid closed, but if we hit this code we are running, so suspend at Tue > Nov 19 18:52:38 2024. > lid closed, but if we hit this code we are running, so suspend at Tue > Nov 19 19:02:07 2024. > lid open at Tue Nov 19 19:55:41 2024. It woke up 5 spurious times while was out! -kb P.S. Is this something I can blame systemd for? No? Well, it was worth the try.
- Follow-Ups:
- [Discuss] Suspend is Great…When it Sticks
- From: richard.pieri at gmail.com (Rich Pieri)
- [Discuss] Suspend is Great…When it Sticks
- Prev by Date: [Discuss] Boston Linux VIRTUAL Meeting , reminder, tomorrow, Wednesday, November 20, 2024 - Leveraging AI Assistance in Python Projects
- Next by Date: [Discuss] Suspend is Great…When it Sticks
- Previous by thread: [Discuss] Boston Linux VIRTUAL Meeting , reminder, tomorrow, Wednesday, November 20, 2024 - Leveraging AI Assistance in Python Projects
- Next by thread: [Discuss] Suspend is Great…When it Sticks
- Index(es):