How is this not a built-in function of pacman?
It’s not really an answer to your question, but you can let any shell command inhibit sleep by running it through
systemd-inhibit, e.g.sudo systemd-inhibit pacman -Syu.Well that’s freaking useful innit, wow. Thank you for that!
Why should it?
Downloads are interrupted by sleep, but they can be safely interrupted.
Installing packages or other core changes are not interrupted by entering sleep mode. Although, they would be interrupted by shutdown/rebooting, sometimes to catastrophic consequences.
Other distros are a bit more resilient, with things like installing and managing multiple kernels, that way even if one breaks (like via a borked/interrupted update), you can still boot.
But pacman/Arch Linux is designed with a certain philosphy in mind. You are supposed to be reading the pacman output, that way you can respond if anything needs to be done. If you don’t respond accordingly when certain manual changes are needed, then bad things can happen. For example, if the grub package gets updated, then you might need to manually generate a new grub config file. If the grub config file and grub itself are out of sync, your system could be rendered unbootable.
One good reason is so that you can start an update, walk away, and it’ll run to completion.
I don’t think it’s a good idea to walk away from a system update, but maybe that’s just me.
So then Unix philosophy way just
yes pacman -Syyu && systemctl suspendor whatever. It only runs if the update is successful, and waits until it’s finished, orpacman -Syyu; systemctl suspendif you want it to suspend regardless of success or failureEdit: misread, thought the question was about making the computer sleep after being finished. Keeping it awake is a blessing and curse about Linux because what is keeping that specific arch build awake, lightdm? Sddm? Systemd? Ideally this would be a systemd capability, but then people would complain about more systemd ownership of bespoke os features. So then use something like https://wakepy.readthedocs.io/stable/index.html I guess otherwise you’re using KDE or gnome or whatever apps
The correct solution is to use systemd-inhibit to block sleep/shutdown (on systemd distros at least).
sudo systemd-inhibit --what=shutdown:sleep --mode=block pacman -SyuEDIT: Oop someone already mentioned systemd-inhibit in another commend. And their answer is even shorter than mine and apparently still works.
Ah TIL, thanks
Neither of these actually inhibit sleep during the update though…
Why should it?
I think it makes sense to not go sleep when the user manually starts an update process. The question is, why shouldn’t it?
I think this would be a user friendly behavior, yes.
But I don’t use Arch because it’s user friendly. In fact, these kinds of patches and glue are what pushed me away from other distros. I was frustrated with the way that they would make the system behavior unpredictable, as developers would begin to guess what I want instead of giving me an opportunity to be explicit. While it’s great when they guess correctly, it’s immensely annoying when they guess incorrectly. And when things like these broke or had bugs, which becomes more likely the more of them and the more complex they are, the abrupt change of system behavior irritates me as well. I prefer the simplicity of Arch Linux, as this trait makes it predictable and easy for me to work with.
https://wiki.archlinux.org/title/Arch_Linux#Simplicity
As an example:
It does not add automation features such as enabling a service simply because the package was installed
I find this quite annoying on other distros actually (although it’s much less annoying on servers vs laptops). But many people find it reasonable and user friendly.
When I desire to inhibit sleep, whether for an update via pacman, or for nix home manager, or any other reason, I usually use KDE’s power management widget. The advantage of this, as opposed to something pacman specific, is that it is explicit, activating and stopping when I want it to, which also makes it more general, and it can be used for anything.

You can also manually do this (on systemd distros at least) via the
systemd-inhibitcommand, which can wait for a command to finish.sudo systemd-inhibit --what=shutdown:sleep --mode=block pacman -SyuSimple, predictable, works on any distro I would throw it against, and it is less likely to break due to weird/complex interactions having bugs.
I don’t even think this has anything to do with being user friendly. I think it is just bad design to go sleep when the user started an update process. To me, there is no reason to sleep, unless the user specifically allows it off course.
But even if its user friendly behavior, it does not mean it cannot be integrated into Archlinux. I don’t know where this mindset comes from that user friendly behavior is not a design goal of Arch, and in fact, I think Arch is one of the most user friendly distributions with its wiki and what it allows to do. It comes down to what type of user you are. User friendly doesn’t automatically mean “beginner”. Archlinux is driven by manual configuration and knowing exactly what happens, without surprises (at least that’s my interpretation). And for those users, Archlinux is perfectly user friendly.
And having said this, preventing the system going to sleep while the user manually started an upgrade / update process isn’t against the philosophy.
It does not add automation features such as enabling a service simply because the package was installed
Not going to sleep is not an automation feature. To me this is a core design decision. If the system can go to sleep while doing so, to me this is not an optional automation feature, it is a flaw, a bug if you will. Therefore this quote from the wiki is unrelated.
systemd-inhibit command, which can wait for a command to finish
This is actually great. Didn’t know systemd can do that already. Now the reality is, my system always updates very quickly and I never had an issue with going to sleep while doing so. That’s why I will not use this functionality, but it is good to know. In fact I will create an alias for this right after I post this reply. Thanks. But my main point and argumentation stands.
don’t know where this mindset comes from that user friendly behavior is not a design goal of Arch
https://wiki.archlinux.org/title/Arch_Linux#User_centrality
Whereas many GNU/Linux distributions attempt to be more user-friendly, Arch Linux has always been, and shall always remain user-centric
user-centric is user-friendly. Even their listed points are for being user-friendly. This is just poor wording and confusing. I guess how they differentiate is, the goal is to be user-specific friendly, than being average-user friendly. This distinction is not what I am talking about. And most people don’t talk about this difference too, they usually say Archlinux is very user unfriendly; for the individual or generalized.
Human language is not very precise and has multiple meanings. Depending on the context we can get different understandings.
If you’re asking that question, just go with a different distro.
If the AUR bothers you, just go with a different distro. Instead telling others what they can do with it.
Thanks for answering. I guess having a laptop fully charged but not on AC-power doing even the smallest update still enters sleep for some reason, even during installation of new files for me
When I desire to inhibit sleep, whether for an update via pacman, or for nix home manager, or any other reason, I usually use KDE’s power management widget. The advantage of this, as opposed to something pacman specific, is that it is explicit, activating and stopping when I want it to, which also makes it more general, and it can be used for anything.

You can also manually do this (on systemd distros at least) via the
systemd-inhibitcommand, which can wait for a command to finish.sudo systemd-inhibit --what=shutdown:sleep --mode=block pacman -SyuEDIT Oop someone already mentioned systemd-inhibit in another commend. And their answer is even shorter than mine and apparently still works.
Idk if you’re looking for a solution, but if you are… I think
systemd-inhibitis what you’re looking for. Something likesystemd-inhibit --what=sleep pacman -Syushould work.I don’t remember what the Linux equivalent is but in macOS I just prefix commands with
caffeinate. It’s super helpful when I want to do things like restore a large database then walk away. I can’t imagine it doesn’t exist on Linux.It might need a d-bus hook built into it, idk
I think other packet managers don’t, either.
As an upside you won’t run into situations like a big Windows update blocking the entire computer 20mins before your meeting and you’d really need to close the lid, throw it in the backpack and walk to the meeting room. Or you spontaneously talk to someone and return to a laptop with a drained battery. Probably more of an issue with automatic-upgrades, though.
Zypper and dnf do block suspend during download and installation of packages, I see them as ‘sleep blockers’ in KDE’s battery settings, unlike for pacman
Oh nice. I think I had both my Debian and my NixOS go to sleep.






