Hibernation issues

Issue: I want to understand how hibernate is supposed to be initiated.
Description: I installed garuda sway and with hibernate enabled. hibernate does work well but i was wondering exactly how to use it. I know i could just run “systemctl hibernate” but that seems counter intuitive especially with the presence of nwgbar.
nwgbar has a suspend option which seems to work like sleep. I had gone through a similar post, the op had posted his /etc/systemd/sleep.conf file and he had some parts commented out. Right now, i think suspend also lead to hibernation depending on the sleep.conf but I have not found anything to confirm this line of thought. I am wondering if there is a reason that a hibernate option is not added by default to nwgbar or if i missed something along the way.
Present workaround: what i have done for the mean time is modify what remove the suspend option and add a hibernate option that runs “systemctl hibernate”

garuda-inxi

System:
  Kernel: 6.10.8-zen1-1-zen arch: x86_64 bits: 64 compiler: gcc v: 14.2.1
    clocksource: tsc avail: acpi_pm
    parameters: BOOT_IMAGE=/@/boot/vmlinuz-linux-zen
    root=UUID=484dd57a-5f67-40db-ab5f-2140b1215e18 rw rootflags=subvol=@
    quiet resume=UUID=ded305a3-d141-4206-9cb8-a3535afadfb9 loglevel=3 ibt=off
  Desktop: Sway v: 0.4 with: waybar tools: swayidle avail: swaylock
    lm: greetd Distro: Garuda base: Arch Linux
Machine:
  Type: Laptop System: HP product: HP EliteBook 840 G7 Notebook PC v: SBKPF
    serial: <filter> Chassis: type: 10 serial: <filter>
  Mobo: HP model: 8723 v: KBC Version 06.4A.00 serial: <filter>
    part-nu: 1D0F2UT#ABA uuid: a88509b5-37b8-40fb-b9f5-d25840f408f0 UEFI: HP
    v: S70 Ver. 01.17.00 date: 04/12/2024
Battery:
  ID-1: BAT0 charge: 44.1 Wh (96.5%) condition: 45.7/53.2 Wh (85.9%)
    volts: 12.5 min: 11.6 model: Hewlett-Packard Primary type: Li-ion
    serial: <filter> status: discharging cycles: 161
CPU:
  Info: model: Intel Core i7-10810U socket: BGA1510 (U3E1) note: check
    bits: 64 type: MT MCP arch: Comet Lake gen: core 10 level: v3 note: check
    built: 2020 process: Intel 14nm family: 6 model-id: 0xA6 (166) stepping: 0
    microcode: 0xFE
  Topology: cpus: 1x cores: 6 tpc: 2 threads: 12 smt: enabled cache:
    L1: 384 KiB desc: d-6x32 KiB; i-6x32 KiB L2: 1.5 MiB desc: 6x256 KiB
    L3: 12 MiB desc: 1x12 MiB
  Speed (MHz): avg: 441 high: 900 min/max: 400/4900 base/boost: 990/4900
    scaling: driver: intel_pstate governor: powersave volts: 0.7 V
    ext-clock: 100 MHz cores: 1: 400 2: 400 3: 400 4: 400 5: 400 6: 400 7: 400
    8: 400 9: 400 10: 400 11: 400 12: 900 bogomips: 38399
  Flags: avx avx2 ht lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx
  Vulnerabilities: <filter>
Graphics:
  Device-1: Intel Comet Lake UHD Graphics vendor: Hewlett-Packard driver: i915
    v: kernel arch: Gen-9.5 process: Intel 14nm built: 2016-20 ports:
    active: eDP-1 empty: DP-1, DP-2, HDMI-A-1, HDMI-A-2 bus-ID: 00:02.0
    chip-ID: 8086:9bca class-ID: 0300
  Device-2: Luxvisions Innotech HP HD Camera driver: uvcvideo type: USB
    rev: 2.0 speed: 480 Mb/s lanes: 1 mode: 2.0 bus-ID: 1-2:2 chip-ID: 30c9:000f
    class-ID: 0e02 serial: <filter>
  Display: wayland server: Xwayland v: 24.1.2 compositor: Sway v: 0.4
    driver: gpu: i915 display-ID: 1
  Monitor-1: eDP-1 model: AU Optronics 0x068b built: 2019 res: 1920x1080
    dpi: 158 gamma: 1.2 size: 309x174mm (12.17x6.85") diag: 355mm (14")
    ratio: 16:9 modes: 1920x1080
  API: Vulkan Message: No Vulkan data available.
  API: EGL Message: EGL data requires eglinfo. Check --recommends.
Audio:
  Device-1: Intel Comet Lake PCH-LP cAVS vendor: Hewlett-Packard
    driver: sof-audio-pci-intel-cnl alternate: snd_hda_intel, snd_soc_skl,
    snd_soc_avs, snd_sof_pci_intel_cnl bus-ID: 00:1f.3 chip-ID: 8086:02c8
    class-ID: 0401
  API: ALSA v: k6.10.8-zen1-1-zen status: kernel-api
    tools: alsactl,alsamixer,amixer
  Server-1: sndiod v: N/A status: off tools: aucat,midicat,sndioctl
  Server-2: PipeWire v: 1.2.3 status: active with: 1: pipewire-pulse
    status: active 2: wireplumber status: active 3: pipewire-alsa type: plugin
    4: pw-jack type: plugin tools: pactl,pw-cat,pw-cli,wpctl
Network:
  Device-1: Intel Comet Lake PCH-LP CNVi WiFi driver: iwlwifi v: kernel
    bus-ID: 00:14.3 chip-ID: 8086:02f0 class-ID: 0280
  IF: wlp0s20f3 state: down mac: <filter>
  IF-ID-1: wwan0 state: down mac: N/A
  Info: services: NetworkManager, smbd, systemd-timesyncd, wpa_supplicant
Bluetooth:
  Device-1: Intel AX201 Bluetooth driver: btusb v: 0.8 type: USB rev: 2.0
    speed: 12 Mb/s lanes: 1 mode: 1.1 bus-ID: 1-10:8 chip-ID: 8087:0026
    class-ID: e001
  Report: btmgmt ID: hci0 rfk-id: 2 state: up address: <filter> bt-v: 5.2
    lmp-v: 11 status: discoverable: no pairing: no class-ID: 6c010c
Drives:
  Local Storage: total: 476.94 GiB used: 10.79 GiB (2.3%)
  SMART Message: Required tool smartctl not installed. Check --recommends
  ID-1: /dev/nvme0n1 maj-min: 259:0 vendor: Samsung
    model: MZVLB512HBJQ-000H1 size: 476.94 GiB block-size: physical: 512 B
    logical: 512 B speed: 31.6 Gb/s lanes: 4 tech: SSD serial: <filter>
    fw-rev: HPS0NEXF temp: 33.9 C scheme: GPT
Partition:
  ID-1: / raw-size: 460.18 GiB size: 460.18 GiB (100.00%)
    used: 10.79 GiB (2.3%) fs: btrfs block-size: 4096 B dev: /dev/nvme0n1p2
    maj-min: 259:2
  ID-2: /boot/efi raw-size: 300 MiB size: 299.4 MiB (99.80%)
    used: 584 KiB (0.2%) fs: vfat block-size: 512 B dev: /dev/nvme0n1p1
    maj-min: 259:1
  ID-3: /home raw-size: 460.18 GiB size: 460.18 GiB (100.00%)
    used: 10.79 GiB (2.3%) fs: btrfs block-size: 4096 B dev: /dev/nvme0n1p2
    maj-min: 259:2
  ID-4: /var/log raw-size: 460.18 GiB size: 460.18 GiB (100.00%)
    used: 10.79 GiB (2.3%) fs: btrfs block-size: 4096 B dev: /dev/nvme0n1p2
    maj-min: 259:2
  ID-5: /var/tmp raw-size: 460.18 GiB size: 460.18 GiB (100.00%)
    used: 10.79 GiB (2.3%) fs: btrfs block-size: 4096 B dev: /dev/nvme0n1p2
    maj-min: 259:2
Swap:
  Kernel: swappiness: 133 (default 60) cache-pressure: 100 (default) zswap: no
  ID-1: swap-1 type: zram size: 14.97 GiB used: 0 KiB (0.0%) priority: 100
    comp: zstd avail: lzo,lzo-rle,lz4,lz4hc,842 max-streams: 12 dev: /dev/zram0
  ID-2: swap-2 type: partition size: 16.46 GiB used: 0 KiB (0.0%)
    priority: -2 dev: /dev/nvme0n1p3 maj-min: 259:3
Sensors:
  System Temperatures: cpu: 40.0 C pch: 41.0 C mobo: N/A
  Fan Speeds (rpm): N/A
Info:
  Memory: total: 16 GiB available: 14.97 GiB used: 1.21 GiB (8.1%)
    igpu: 512 MiB
  Processes: 292 Power: uptime: 4h 59m states: freeze,mem,disk
    suspend: s2idle avail: deep wakeups: 0 hibernate: platform avail: shutdown,
    reboot, suspend, test_resume image: 5.98 GiB
    services: power-profiles-daemon Init: systemd v: 256 default: graphical
    tool: systemctl
  Packages: pm: pacman pkgs: 1320 libs: 413 tools: pacseek,paru Compilers:
    gcc: 14.2.1 Shell: garuda-inxi (sudo) default: Bash v: 5.2.32
    running-in: foot inxi: 3.3.35
Garuda (2.6.26-1):
  System install date:     2024-09-07
  Last full system update: 2024-09-08
  Is partially upgraded:   No
  Relevant software:       snapper NetworkManager dracut
  Windows dual boot:       No/Undetected
  Failed units:
/etc/systemd/sleep.conf

#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it under the
#  terms of the GNU Lesser General Public License as published by the Free
#  Software Foundation; either version 2.1 of the License, or (at your option)
#  any later version.
#
# Entries in this file show the compile time defaults. Local configuration
# should be created by either modifying this file (or a copy of it placed in
# /etc/ if the original file is shipped in /usr/), or by creating "drop-ins" in
# the /etc/systemd/sleep.conf.d/ directory. The latter is generally
# recommended. Defaults can be restored by simply deleting the main
# configuration file and all drop-ins located in /etc/.
#
# Use 'systemd-analyze cat-config systemd/sleep.conf' to display the full config.
#
# See systemd-sleep.conf(5) for details.

[Sleep]
#AllowSuspend=yes
#AllowHibernation=yes
#AllowSuspendThenHibernate=yes
#AllowHybridSleep=yes
#SuspendState=mem standby freeze
#HibernateMode=platform shutdown
#MemorySleepMode=
#HibernateDelaySec=
#SuspendEstimationSec=60min

It’s not an issue want to learn, but this forum is not a general support forum.
I move it from Issues & Assistance to Sway
because I think @BluishHumility will now write a little essay about it or possibly make changes in Sway :smiley:

https://wiki.archlinux.org/title/Power_management/Suspend_and_hibernate

2 Likes

Who, me?! :innocent:


The way Sway handles suspend and hibernate in Garuda Linux is very simple: it doesn’t! :smiley:

A while back I dropped the somewhat hacky swayidle > swaylock > swaymsg "output * dpms off" “suspend” routine that Sway ships with, along with the associated scripts for handing clamshell events and so on, in favor of just letting systemd handle all this stuff. feat(default-sway-config): add idlehint, remove swayidle suspend routine (17cd70af) · Commits · Garuda Linux 🦅 / Themes and Settings / Settings / Garuda Sway settings · GitLab. Garuda Linux already uses systemd anyway; it seems like a much cleaner and simpler solution to use that implementation for suspend and hibernate events.

That is to say, this is the correct way to configure suspend and hibernate on Garuda Sway:

There is not a default hibernation configuration, because hibernation itself is not configured by default. The user will need to explicitly set it up themselves if they want to use it.

Sway does ship with a drop-in for /etc/systemd/logind.conf.d, which defines a default behavior of suspending the computer after ten minutes of idle time. garuda/sway/desktop-overlay/etc/systemd/logind.conf.d/suspend.conf · cb9c2ab11c3e13be99a9eb3a0d04b6afca4c215f · Garuda Linux 🦅 / Tools / iso-profiles · GitLab


This is kind of a matter of user preference; pretty much any method of triggering suspend is supported, so you should think about how you want it to be set up and then work toward that.

A common way to handle hibernation is using suspend-then-hibernate, which does pretty much what it says: it suspends the system to RAM, then after the battery drops to a certain level or a certain amount of time passes it hibernates. I think this is probably most similar to the behavior of Windows or other OS’s.

To configure this, edit the drop-in file I mentioned above and change suspend to suspend-then-hibernate.

sudo micro /etc/systemd/logind.conf.d/suspend.conf
[Login]
IdleAction=suspend-then-hibernate
IdleActionSec=10min

The above example will start the suspend-then-hibernate action after ten minutes of idle time.

Look through /etc/systemd/logind.conf to see if there are any other actions you want to set up. For example, you can kick off hibernate or suspend-then-hibernate after closing the lid (if you have a laptop) or pressing the hibernate button if you have one on your keyboard. You can either directly edit /etc/systemd/logind.conf or create a drop-in file in /etc/systemd/logind.conf.d (the latter is recommended).

If you want, you can add additional actions right to the same drop-in file mentioned above.

[Login]
IdleAction=suspend-then-hibernate
IdleActionSec=10min
HandleLidSwitch=suspend-then-hibernate
HandlePowerKey=suspend-then-hibernate

See also: logind.conf(5) — Arch manual pages, or:

man logind.conf

Once you have an action defined for starting suspend-then-hibernate, the computer will switch from suspend to hibernate when the battery drops to 5%, or after two hours have passed (whichever happens first). If you want hibernation to happen more quickly (or slowly), you can set that up in /etc/systemd/sleep.conf by setting the HibernateDelaySec= to however long you want the computer to wait before switching from suspend to hibernate.

For example, if you are using suspend-then-hibernate and want the computer to switch to hibernation after ten minutes in suspend, edit /etc/systemd/sleep.conf or add a drop-in file to /etc/systemd/sleep.conf.d like this:

sudo micro /etc/systemd/sleep.conf.d/my_hibernation_config.conf
[Sleep]
HibernateDelaySec=10min

Building on the previous example, now the complete action is to suspend the computer after ten minutes of idle time, then wait another ten minutes, then switch to hibernation (after 20 minutes total).

See also: systemd-sleep.conf(5) — Arch manual pages, or:

man systemd-sleep.conf

Edit: I almost forgot to mention, you will need to restart the systemd-logind service after editing these files to apply the changes.

sudo systemctl restart systemd-logind

As for nwg-bar, you can customize it as you see fit by editing ~/.config/nwg-launchers/nwgbar/bar.json. Check it out, I just added a button to launch Mousepad (the text editor) and named it “Why would anyone do this”:

[
  {
    "name": "Lock screen",
    "exec": "swaylock",
    "icon": "/usr/share/nwg-launchers/nwgbar/images/lock.svg"
  },
  {
  	"name": "Suspend",
    "exec": "systemctl suspend",
  	"icon": "/usr/share/nwg-launchers/nwgbar/images/suspend.svg"
  },
  {
    "name": "Why would anyone do this",
    "exec": "mousepad",
    "icon": "org.xfce.mousepad"
  },
  {
    "name": "Logout",
    "exec": "loginctl terminate-session self",
    "icon": "/usr/share/nwg-launchers/nwgbar/images/logout.svg"
  },
  {
    "name": "Reboot",
    "exec": "systemctl reboot",
    "icon": "/usr/share/nwg-launchers/nwgbar/images/reboot.svg"
  },
  {
    "name": "Shutdown",
    "exec": "systemctl -i poweroff",
    "icon": "/usr/share/nwg-launchers/nwgbar/images/shutdown.svg"
  }
]

And yes, it launches Mousepad when I click on it. :wink:

2 Likes

thanks for the detailed reply

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.