How is this not a built-in function of pacman?

  • moonpiedumplings@programming.dev
    link
    fedilink
    English
    arrow-up
    28
    arrow-down
    3
    ·
    1 day ago

    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.

    https://wiki.archlinux.org/title/Arch_Linux#User_centrality

    • frongt@lemmy.zip
      link
      fedilink
      arrow-up
      11
      arrow-down
      2
      ·
      1 day ago

      One good reason is so that you can start an update, walk away, and it’ll run to completion.

      • Victor@lemmy.world
        link
        fedilink
        arrow-up
        3
        arrow-down
        2
        ·
        22 hours ago

        I don’t think it’s a good idea to walk away from a system update, but maybe that’s just me.

      • urushitan 漆たん@kakera.kintsugi.moe
        link
        fedilink
        arrow-up
        4
        arrow-down
        5
        ·
        edit-2
        20 hours ago

        So then Unix philosophy way just yes pacman -Syyu && systemctl suspend or whatever. It only runs if the update is successful, and waits until it’s finished, or pacman -Syyu; systemctl suspend if you want it to suspend regardless of success or failure

        Edit: 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

        • moonpiedumplings@programming.dev
          link
          fedilink
          English
          arrow-up
          3
          ·
          edit-2
          13 hours ago

          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 -Syu
          

          EDIT: Oop someone already mentioned systemd-inhibit in another commend. And their answer is even shorter than mine and apparently still works.

    • thingsiplay@lemmy.ml
      link
      fedilink
      arrow-up
      3
      ·
      23 hours ago

      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?

      • moonpiedumplings@programming.dev
        link
        fedilink
        English
        arrow-up
        3
        ·
        13 hours ago

        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-inhibit command, which can wait for a command to finish.

        sudo systemd-inhibit --what=shutdown:sleep --mode=block pacman -Syu
        

        Simple, predictable, works on any distro I would throw it against, and it is less likely to break due to weird/complex interactions having bugs.

        • thingsiplay@lemmy.ml
          link
          fedilink
          arrow-up
          3
          ·
          12 hours ago

          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.

            • thingsiplay@lemmy.ml
              link
              fedilink
              arrow-up
              1
              ·
              5 hours ago

              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.

        • thingsiplay@lemmy.ml
          link
          fedilink
          arrow-up
          1
          ·
          17 hours ago

          If the AUR bothers you, just go with a different distro. Instead telling others what they can do with it.

    • HogGirl@sh.itjust.worksOP
      link
      fedilink
      English
      arrow-up
      4
      ·
      1 day ago

      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

      • moonpiedumplings@programming.dev
        link
        fedilink
        English
        arrow-up
        3
        ·
        13 hours ago

        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-inhibit command, which can wait for a command to finish.

        sudo systemd-inhibit --what=shutdown:sleep --mode=block pacman -Syu
        

        EDIT Oop someone already mentioned systemd-inhibit in another commend. And their answer is even shorter than mine and apparently still works.