System does not hibernate at critical battery level

Hello Garuda users.
I recently had a situation with my laptop where my battery went past critical battery levels and then died at 0%. However, I have turned on my KDE settings to hibernate my system at critical battery levels. This didn't happen.

A search on the net told me that's it's an old kde issue that has been fixed by upstream. But it still doesn't work for me for some reason. My hibernate itself has worked fine in the past. But in this case after my battery went past critical battery levels I wasn't even notified.
No notification
No actions nothing of the sort were visually attempted by my system it just went black screen at 0% battery.

System:
Kernel: 6.0.11-zen1-1-zen arch: x86_64 bits: 64 compiler: gcc v: 12.2.0
parameters: BOOT_IMAGE=/@/boot/vmlinuz-linux-zen
root=UUID=6a7bcee6-f3ae-4c03-b6b0-7cb27fb4c8d4 rw rootflags=subvol=@
quiet quiet splash rd.udev.log_priority=3 vt.global_cursor_default=0
resume=UUID=1b9b6f2d-a19b-4eee-b2bf-6af31dfdf566 loglevel=3 ibt=off
Desktop: KDE Plasma v: 5.26.4 tk: Qt v: 5.15.7 info: latte-dock
wm: kwin_x11 vt: 1 dm: SDDM Distro: Garuda Linux base: Arch Linux
Machine:
Type: Convertible System: LENOVO product: 81X1 v: IdeaPad Flex 5 14IIL05
serial: <superuser required> Chassis: type: 31 v: IdeaPad Flex 5 14IIL05
serial: <superuser required>
Mobo: LENOVO model: LNVNB161216 v: SDK0Q55722 WIN
serial: <superuser required> UEFI: LENOVO v: ECCN41WW date: 06/27/2022
Battery:
ID-1: BAT0 charge: 15.6 Wh (35.8%) condition: 43.6/52.6 Wh (82.8%)
volts: 11.9 min: 11.5 model: Sunwoda L19D3PD6 type: Li-poly serial: <filter>
status: charging cycles: 1268
Device-1: wacom_battery_0 model: Wacom HID 5218 serial: N/A charge: 0%
rechargeable: yes status: N/A
CPU:
Info: model: Intel Core i7-1065G7 bits: 64 type: MT MCP arch: Ice Lake
gen: core 10 level: v4 note: check built: 2019-21 process: Intel 10nm
family: 6 model-id: 0x7E (126) stepping: 5 microcode: 0xB6
Topology: cpus: 1x cores: 4 tpc: 2 threads: 8 smt: enabled cache:
L1: 320 KiB desc: d-4x48 KiB; i-4x32 KiB L2: 2 MiB desc: 4x512 KiB L3: 8 MiB
desc: 1x8 MiB
Speed (MHz): avg: 1434 high: 1500 min/max: 400/3900 scaling:
driver: intel_pstate governor: powersave cores: 1: 1500 2: 975 3: 1500
4: 1500 5: 1500 6: 1500 7: 1500 8: 1500 bogomips: 23961
Flags: avx avx2 ht lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx
Vulnerabilities:
Type: itlb_multihit status: KVM: VMX disabled
Type: l1tf status: Not affected
Type: mds status: Not affected
Type: meltdown status: Not affected
Type: mmio_stale_data mitigation: Clear CPU buffers; SMT vulnerable
Type: retbleed mitigation: Enhanced IBRS
Type: spec_store_bypass mitigation: Speculative Store Bypass disabled via
prctl
Type: spectre_v1 mitigation: usercopy/swapgs barriers and __user pointer
sanitization
Type: spectre_v2 mitigation: Enhanced IBRS, IBPB: conditional, RSB
filling, PBRSB-eIBRS: SW sequence
Type: srbds mitigation: Microcode
Type: tsx_async_abort status: Not affected
Graphics:
Device-1: Intel Iris Plus Graphics G7 vendor: Lenovo driver: i915 v: kernel
arch: Gen-11 process: Intel 10nm built: 2019-21 ports: active: eDP-1
empty: DP-1, DP-2, DP-3, HDMI-A-1 bus-ID: 00:02.0 chip-ID: 8086:8a52
class-ID: 0300
Device-2: NVIDIA GP108M [GeForce MX330] vendor: Lenovo driver: nvidia
v: 525.60.11 alternate: nouveau,nvidia_drm non-free: 520.xx+
status: current (as of 2022-10) arch: Pascal code: GP10x
process: TSMC 16nm built: 2016-21 pcie: gen: 1 speed: 2.5 GT/s lanes: 4
link-max: gen: 3 speed: 8 GT/s bus-ID: 01:00.0 chip-ID: 10de:1d16
class-ID: 0302
Device-3: Acer Integrated Camera type: USB driver: uvcvideo bus-ID: 3-2:2
chip-ID: 5986:212a class-ID: 0e02
Display: x11 server: X.Org v: 21.1.4 with: Xwayland v: 22.1.5
compositor: kwin_x11 driver: X: loaded: modesetting,nvidia unloaded: nouveau
alternate: fbdev,intel,nv,vesa dri: iris gpu: i915 display-ID: :0
screens: 1
Screen-1: 0 s-res: 1920x1080 s-dpi: 96 s-size: 508x285mm (20.00x11.22")
s-diag: 582mm (22.93")
Monitor-1: eDP-1 model: ChiMei InnoLux 0x1406 built: 2019 res: 1920x1080
hz: 60 dpi: 158 gamma: 1.2 size: 309x173mm (12.17x6.81") diag: 354mm (13.9")
ratio: 16:9 modes: 1920x1080
API: OpenGL v: 4.6 Mesa 22.2.3 renderer: Mesa Intel Iris Plus Graphics
(ICL GT2) direct render: Yes
Audio:
Device-1: Intel Ice Lake-LP Smart Sound Audio vendor: Lenovo
driver: sof-audio-pci-intel-icl
alternate: snd_hda_intel,snd_sof_pci_intel_icl bus-ID: 00:1f.3
chip-ID: 8086:34c8 class-ID: 0401
Sound API: ALSA v: k6.0.11-zen1-1-zen running: yes
Sound Server-1: PulseAudio v: 16.1 running: no
Sound Server-2: PipeWire v: 0.3.61 running: yes
Network:
Device-1: Intel Ice Lake-LP PCH CNVi WiFi driver: iwlwifi v: kernel
bus-ID: 00:14.3 chip-ID: 8086:34f0 class-ID: 0280
IF: wlp0s20f3 state: up mac: <filter>
Bluetooth:
Device-1: Intel AX201 Bluetooth type: USB driver: btusb v: 0.8
bus-ID: 3-10:4 chip-ID: 8087:0026 class-ID: e001
Report: bt-adapter ID: hci0 rfk-id: 2 state: up address: <filter>
Drives:
Local Storage: total: 476.94 GiB used: 37.44 GiB (7.8%)
SMART Message: Unable to run smartctl. Root privileges required.
ID-1: /dev/nvme0n1 maj-min: 259:0 vendor: Samsung
model: MZALQ512HALU-000L2 size: 476.94 GiB block-size: physical: 512 B
logical: 512 B speed: 31.6 Gb/s lanes: 4 type: SSD serial: <filter>
rev: 3L1QFXV7 temp: 27.9 C scheme: GPT
Partition:
ID-1: / raw-size: 459.82 GiB size: 459.82 GiB (100.00%)
used: 37.44 GiB (8.1%) fs: btrfs dev: /dev/nvme0n1p2 maj-min: 259:2
ID-2: /boot/efi raw-size: 300 MiB size: 299.4 MiB (99.80%)
used: 608 KiB (0.2%) fs: vfat dev: /dev/nvme0n1p1 maj-min: 259:1
ID-3: /home raw-size: 459.82 GiB size: 459.82 GiB (100.00%)
used: 37.44 GiB (8.1%) fs: btrfs dev: /dev/nvme0n1p2 maj-min: 259:2
ID-4: /var/log raw-size: 459.82 GiB size: 459.82 GiB (100.00%)
used: 37.44 GiB (8.1%) fs: btrfs dev: /dev/nvme0n1p2 maj-min: 259:2
ID-5: /var/tmp raw-size: 459.82 GiB size: 459.82 GiB (100.00%)
used: 37.44 GiB (8.1%) fs: btrfs dev: /dev/nvme0n1p2 maj-min: 259:2
Swap:
Kernel: swappiness: 133 (default 60) cache-pressure: 100 (default)
ID-1: swap-1 type: zram size: 15.29 GiB used: 0 KiB (0.0%) priority: 100
dev: /dev/zram0
ID-2: swap-2 type: partition size: 16.82 GiB used: 0 KiB (0.0%)
priority: -2 dev: /dev/nvme0n1p3 maj-min: 259:3
Sensors:
System Temperatures: cpu: 64.0 C mobo: N/A
Fan Speeds (RPM): N/A
Info:
Processes: 299 Uptime: 44m wakeups: 18 Memory: 15.29 GiB
used: 5.93 GiB (38.8%) Init: systemd v: 252 default: graphical
tool: systemctl Compilers: gcc: 12.2.0 Packages: pm: pacman pkgs: 1306
libs: 353 tools: octopi,pamac,paru Shell: fish v: 3.5.1 default: Bash
v: 5.1.16 running-in: konsole inxi: 3.3.23
Garuda (2.6.10-1):
System install date:     2022-11-12
Last full system update: 2022-12-09
Is partially upgraded:   No
Relevant software:       NetworkManager
Windows dual boot:       Probably (Run as root to verify)
Snapshots:               Snapper
Failed units:

Could someone please suggest me what I should do?

What was your method for setting up hibernation?

Have you tested hibernation after setting it up, aside from this KDE battery thing? What happens if you run:

sudo systemctl hibernate

Post the output of:

cat /etc/systemd/sleep.conf

When I installed garuda from calameres installer I choose Swap [With hibernate] when installing and nothing else. After that hibernate has worked out of the box for me though my laptop does not automatically go to hibernate mode after being asleep for a while but when I click the hibernate button it does and resumes with no problem so far.

I ran the command happened the same thing as clicking the hibernate button does and the system resumed with no problem.

File: /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 by creating "drop-ins" in
# the sleep.conf.d/ subdirectory. The latter is generally recommended.
# Defaults can be restored by simply deleting this file and all drop-ins.
#
# See systemd-sleep.conf(5) for details.

[Sleep]
#AllowSuspend=yes
#AllowHibernation=yes
#AllowSuspendThenHibernate=yes
#AllowHybridSleep=yes
#SuspendMode=
#SuspendState=mem standby freeze
#HibernateMode=platform shutdown
#HibernateState=disk
#HybridSleepMode=suspend platform shutdown
#HybridSleepState=disk
#HibernateDelaySec=120min

Yes, I always put my laptop in hibernate mode rather than shutdown when I turn off for the day or am going somewhere and won’t be using my system for a while. infact the only time my system reboots is when it has some kernel update (almost every 3-4 days) or when it runs into some bug

It sounds like suspend is working, just not configured the way you want it.

I think this is what you want:

suspend-then-hibernate

A low power state where initially user.slice unit is freezed. If the hardware supports low-battery alarms (ACPI _BTP), then the system is first suspended (the state is stored in RAM) and then hibernates if the system is woken up by the hardware via ACPI low-battery signal. Unit user.slice is thawed when system returns from hibernation. If the hardware does not support low-battery alarms (ACPI _BTP), then the system is suspended based on battery’s current percentage capacity. If the current battery capacity is higher than 5%, the system suspends for interval calculated using battery discharge rate per hour or HibernateDelaySec= if former is not available. Battery discharge rate per hour is stored in a file which is created after initial suspend-resume cycle. The value is calculated using battery decreasing charge level over a timespan for which system was suspended. For each battery connected to the system, there is a unique entry. After RTC alarm wakeup from suspend, battery discharge rate per hour is again estimated. If the current battery charge level is equal to or less than 5%, the system will be hibernated (the state is then stored on disk) else the system goes back to suspend for the interval calculated using battery discharge rate per hour. In case of manual wakeup, if the battery was discharged while the system was suspended, the battery discharge rate is estimated and stored on the filesystem. In case the system is woken up by the hardware via the ACPI low-battery signal, then it hibernates.

From here.

I’ve never bothered setting up hibernation myself, but it looks like a simple matter of configuring a systemd service. Make sure the options you want are declared in the configs, enable the service, and Bob’s your uncle. systemd-suspend-then-hibernate.service(8) — Arch manual pages

3 Likes

well actually not quite, Sleep and hibernate work just fine for me but the suspend service doesn’t play nice with my device it leaves me with a black screen after resuming. However, I will try your solution and then report again.

1 Like

Hi thanks for your help but I am a little stuck could you please help:
I tried going through the wiki article and edited my sleep.conf file as below:

File: /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 by creating "drop-ins" in
# the sleep.conf.d/ subdirectory. The latter is generally recommended.
# Defaults can be restored by simply deleting this file and all drop-ins.
#
# See systemd-sleep.conf(5) for details.

[Sleep]
AllowSuspend=yes
AllowHibernation=yes
AllowSuspendThenHibernate=yes
#AllowHybridSleep=yes
#SuspendMode=
SuspendState=mem standby freeze
HibernateMode=platform shutdown
HibernateState=disk
#HybridSleepMode=suspend platform shutdown
#HybridSleepState=disk
HibernateDelaySec=1min

And then put my system to sleep which should have made my system go to hibernate mode after HibernateDelaySec but it didn't happen. Did I miss something? Do I have to restart a certain service for these changes to work?

I have also tried using

systemctl suspend (looks like my problem with suspend has been removed after some kernal update)
systemctl suspend-then-hibernate

which also didn’t go to hibernate mode after the timer time out.

Oh re reading the manual again I think this might have happened because my system battery was over 5%. Though I would still like to ask if I have set up mu sleep.conf properly?

Oh I found the proper reason why it isn't working here:
https://bbs.archlinux.org/viewtopic.php?id=248616
it seems KDE is blocking it with powerdevil.
Thanks for your help everyone. :pray:

The issue you linked was resolved a few years ago, in Powerdevil version 5.17 (I believe the current version is 5.26).

If you are trying to use the systemd-suspend-then-hibernate.service, I think your issue may be with configuration.

According to this, SuspendMode should be uncommented and a value specified:

systemd-suspend-then-hibernate.service(8) uses the value of SuspendMode= when suspending and the value of HibernateMode= when hibernating.

If you are not sure what to put (the documentation for this service doesn’t exactly hold your hand) I believe it can just be SuspendMode=Suspend.

Have you tried running the command from the thread you linked to see what inhibitors are listed for your system? Paste them into the thread so we can take a look.

systemd-inhibit --list
WHO            UID  USER      PID  COMM            WHAT                                                                       WHY                                                        MODE
ModemManager   0    root      712  ModemManager    sleep                                                                      ModemManager needs to reset devices                        delay
NetworkManager 0    root      687  NetworkManager  sleep                                                                      NetworkManager needs to turn off networks                  delay
UPower         0    root      1695 upowerd         sleep                                                                      Pause device polling                                       delay
PowerDevil     1000 siddharth 1880 org_kde_powerde handle-power-key:handle-suspend-key:handle-hibernate-key:handle-lid-switch KDE handles power events                                   block
Screen Locker  1000 siddharth 1709 ksmserver       sleep                                                                      Ensuring that the screen gets locked before going to sleep delay

5 inhibitors listed.

Here is the output.

Yes I did do that a while after posting this. I also tried various configurations of sleep.conf and logind.conf people have online for KDE to work with suspend-then-hibernate service.
I also turned on while asleep, hibernate after a period of inactivity which supposedly allows KDE to use suspend-then-hibernate.service. This option in the past has made me get black screens after resuming from sleep. However, while the black screen didn’t immediately start bothering me the service itslef didn’t do anything for me either.

I checked the journalctl which showed system initiated suspend-then-hibernate and turned off 7 cores of my CPU before immediately starting them again for some reason. It didn’t really show me any error for the process or that it failed somewhere. The system never actually went into hibernation for me though and the cat /sys/power/disk showed

platform shutdown reboot [suspend] test_resume

I tried rebooting again and the system started black screeing for me after sleep. So, I just turned off the service again and kinda just gave up.

While all this was happening I noticed that the KDE service of hibernating my system at critical battery levels started working again. I have tried using that service twice so far by consuming my battery to 10% and the system has started giving me notifications and then hibernating after 60 seconds. maybe a reboot or something somewhere I changed made it work. So I am assuming the service failing on me was a one time thing. (atleast I hope so).

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