Linux is cool, I can do a lot of things with it. If i set a config file in Linux, I am damn sure that it is ran every single time. The code does what you tell it to do.
There is 1 thing that always seems to be “black magic”: 1) lid close and suspend 2) lid close and suspend and lock.
If we ignore locking for a moment and focus on suspend. I cant seem to figure out why sometimes lid close would suspend immediately, when other time it takes 5 seconds after lid closes. On some days, lid closes would not even suspend !!
Did anyone manage to get suspend work 100 %? I cant believe we have tons of great linux tools and years into kernel dev, and still suspend is a hit or miss.
Inconsistent time before sleep is likely the kernel waiting for IO to sync to disk.
Not going to sleep at all implies a serious issue that prevented the kernel from doing so. Check your logs!
Suspend reliability greatly depends on the firmware of your specific device as it controls the wakeup.
On my Framework 16 for instance, it is very reliable these days. I can’t remember the last time it woke up unexpectedly and I’m not sure whether it happened even once since the firmware update that fixed a major oversight in keyboard wakeup (waking when a key was pressed through a closed lid).
In Hyprland, how it works is that you define the screen lock command (e.g.
swaylock) in hypridle and that gets wired into logind somehow such that you canloginctl lock-session.I then (also in hypridle) define a before sleep hook that locks the session.
I believe the proper way to do this would be to run your lockscreen as a systemd unit that is
WantedByandBeforesuspend.target. This would in theory take care of making it idempotent and reliably show the lockscreen before initiating suspend.
A friend of mine has this sort of setup and, while it is reliable, the lockscreen is still racy and sometimes only triggers after suspend. Might be the lockscreen unit not signalling its readiness to systemd properly though.how do you make sure that on lid close: the laptop suspends and locks?
I’ve had it fail (ie, stay on and deplete the battery) often enough over the years that I just suspend/hibernate manually before closure.
Few seem to address the issue here : it does not work 100% of the time for you.
It might work for everybody else but that doesn’t help you much. You have your setup, no theirs.
So… you need to investigate. When it works, great, nothing to learn from. When it fails though… can you find a pattern? Does it always fail after you have use something specific? Check https://lemmy.ml/post/46800646/25494455 which gives examples of potential failure point and
journalctllogs. You can then check what failed and if not you can at least know when then backtrack to others logs, e.g.dmesg.They key take away is that when things do not behave as expected you need to put a detective hat on and you investigate :
- what’s your crime scene? Your laptop and it’s log files
- what’s the crime? It didn’t suspend properly
- where are the traces? In the logs
- where are the logs? Using
journalctlordmesgand typically in/var/log/ - what would a good detective do? Search for specific clues, e.g. places where fingerprints do stick, e.g metal or glass, which here would be error messages. That can be found using
grepand other tools
You also have limited times because the logs will, just like on a real crime scene, get contaminated or rotated or deleted. So… if you do encounter the problem do not rush to the next tasks at hand because you are wasting an opportunity to learn and there is vanishing window.
TL;DR : grep logs
This. Marking becauce I also want to learn about it.
In KDE it’s just a simple configuration in the power section of the settings. No idea what the general Linux way would be.
/etc/systemd/logind.confHandleLidSwitch=suspendi dont really close my lid and walk away, i usually just lock the screen and turn off the display if required without suspending.
altho i have noticed users complain that suspend fails after a specific service/application is started so u might wanna check on that
Depends a bit on your setup. If you’re using systemd you can use the logind.conf as already mentioned, or if you’re on a non-systemd distro you can use the forked elogind, which works pretty much the same way. For locking your session when suspending, since i use wayland, i use swayidle for that. In its config i just put
before-sleep 'swaylock', which will execute swaylock before the system goes to sleep.Have a look on the Arch Linux wiki around
udevand event debugging (evdev?)Depending on whether you’re suspending to RAM or disk will affect the time it takes - and of course, how much stuff it has to suspend.
If you’re in the middle of a resource intensive task (which could just be watching a video… all depends…), then whatever is running needs to stop, and possibly has a full buffer which needs processing as suspend could be to the swap file / partition, which may need emptying first.
But, it should all work these days.
I don’t know, I just installed Aurora Linux and everything works by default.
I bet your issue is hardware related, maybe you could change something in the bios to make it work.
What’s Aurora Linux? I checked their website and it’s still unclear to me. Is it immutable?
deleted by creator
Yeah, it’s part of the Universal Blue family of distros which Bazzite is part of. Technically it’s not immutable (they call it atomic), but yeah. For gui apps I just use flatpaks & appimages, for cli apps I do: brew install whatever. 99% of the time this does the trick, for that 1% which is some obscure random app I really want to try, I just use Kontainer which is a GUI for distrobox, basically it let’s me install any linux app for any distro. And for those super rare cases when I need to use a Windows app, I use Winboat which is freaking great.
Aurora now has a live iso, you could try it without installing it and see if everything works out for you.
In other words, it’s Fedora Kinoite with expanded hardware support, a few quality of life improvements and the trustworthyness of an immutable distro. I’ve been rocking it for more than a year, and it’s the same pure bliss of Bazzite (which I run on all my home PCs).
I use Aurora on my work laptop, I’ve installed it in an external M2 caddy drive, so my company has the Windows drive with the license intact, and I’ve set the BIOS to boot to the M2… so my files are all on the external drive which also works as a thumbdrive on my desktop PC at home. When my IT guy said I had to change laptops, I just plugged my M2 drive to the new one and that’s it.
Freaking great. Best experience I’ve ever had with work laptops. Plus, it’s faster than Windows. I love it so much.
It works almost all the time. The times it doesn’t usually can be attributed to me not switching off my wireless mouse.
You ask too much.
Sleep on Linux is never quite as reliable as it should be, and I end up with a laptop gently roasting itself to death in my bag more times than I’d prefer.








