Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
hibernate / suspend to disk / openRC
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
jlm
n00b
n00b


Joined: 27 May 2018
Posts: 52

PostPosted: Mon Apr 29, 2024 7:47 am    Post subject: hibernate / suspend to disk / openRC Reply with quote

Hi,
I have a https://wiki.gentoo.org/wiki/Lenovo_IdeaPad_Yoga_900_13ISK
the S4 (suspend to disk /hibernate) was broken because the wifi module was no more maintained by intel's linux dev.
so I upgraded to
01:00.0 Network controller: Intel Corporation Wi-Fi 6 AX210/AX211/AX411 160MHz (rev 1a)
Subsystem: Intel Corporation Wi-Fi 6 AX210 160MHz
Flags: bus master, fast devsel, latency 0, IRQ 16
Memory at a1100000 (64-bit, non-prefetchable) [size=16K]
Capabilities: <access denied>
Kernel driver in use: iwlwifi
Kernel modules: iwlwifi
and followed the https://wiki.gentoo.org/wiki/Suspend_and_hibernate
after changing grub configuration, changing dracut configuration to handle boot from image I got the S4 working when performing `loginctl hibernate`

BUT I can't make the system enter hibernate on low battery
I tried to start upowerd making openrc script (so now upowerd is started on boot) and upower command reports
Code:

$ upower -d
Device: /org/freedesktop/UPower/devices/battery_BAT1
  native-path:          BAT1
  vendor:               Simplo
  model:                BASE-BAT
  serial:               123456789
  power supply:         yes
  updated:              Mon 29 Apr 2024 09:39:50 AM CEST (2 seconds ago)
  has history:          yes
  has statistics:       yes
  battery
    present:             yes
    rechargeable:        yes
    state:               fully-charged
    warning-level:       none
    energy:              38.72 Wh
    energy-empty:        0 Wh
    energy-full:         38.72 Wh
    energy-full-design:  66 Wh
    energy-rate:         0 W
    voltage:             8.286 V
    charge-cycles:       N/A
    percentage:          100%
    capacity:            58.6667%
    technology:          lithium-polymer
    icon-name:          'battery-full-charged-symbolic'

Device: /org/freedesktop/UPower/devices/line_power_ADP1
  native-path:          ADP1
  power supply:         yes
  updated:              Mon 29 Apr 2024 07:59:43 AM CEST (6009 seconds ago)
  has history:          no
  has statistics:       no
  line-power
    warning-level:       none
    online:              yes
    icon-name:          'ac-adapter-symbolic'

Device: /org/freedesktop/UPower/devices/mouse_dev_DD_49_58_FD_24_9D
  native-path:          /org/bluez/hci0/dev_DD_49_58_FD_24_9D
  model:                BT4.0+2.4G Mouse
  serial:               DD:49:58:FD:24:9D
  power supply:         no
  updated:              Mon 29 Apr 2024 09:22:10 AM CEST (1062 seconds ago)
  has history:          yes
  has statistics:       no
  mouse
    present:             yes
    rechargeable:        no
    state:               unknown
    warning-level:       none
    percentage:          100%
    icon-name:          'battery-missing-symbolic'
  History (charge):
    1714376392  0.000   unknown
  History (rate):
    1714376392  0.000   unknown

Device: /org/freedesktop/UPower/devices/DisplayDevice
  power supply:         yes
  updated:              Sun 28 Apr 2024 10:15:22 AM CEST (84270 seconds ago)
  has history:          no
  has statistics:       no
  battery
    present:             yes
    state:               fully-charged
    warning-level:       none
    energy:              38.72 Wh
    energy-full:         38.72 Wh
    energy-rate:         0 W
    charge-cycles:       N/A
    percentage:          100%
    icon-name:          'battery-full-charged-symbolic'

Daemon:
  daemon-version:  1.90.2
  on-battery:      no
  lid-is-closed:   no
  lid-is-present:  yes
  critical-action: HybridSleep

so is working... buuuut.....
when battery critical level is reached, the system poweroff, and never hibernate....
so, there is something that monitor the battery, and poweroff the system (no dirty "off", services are stopped, disk umounted....) and this is not upowerd that do the work.... I suspect upowerd not working outside systemd, and really prefer openRC, so... what is performing power management on openRC systems? what is too bad with upowerd, is that the command to hybridsleep can't be specified (so can't take advantages of advanced features of https://github.com/bircoph/suspend like image encryption....)
thanks and regards
Back to top
View user's profile Send private message
jlm
n00b
n00b


Joined: 27 May 2018
Posts: 52

PostPosted: Tue Nov 05, 2024 9:14 pm    Post subject: Reply with quote

To reply myself, might help someone....
I ended doing it in a script that I launch in screen at login
Code:

$ cat ~/.local/bin/battery_monitor.sh
#!/bin/sh
criticalLevel=20                                                                                                                 
battery=$(upower -e | grep battery)                                                                                               
while true; do                                                                                                                   
    sleep 2s                                                                                                                     
    BatteryStat=$(upower -i ${battery})                                                                                           
    state=$(printf "%s" "${BatteryStat}" | grep state: | sed "s/[[:space:]]\+state:[[:space:]]\+//")                             
    if [ "${state}" == "discharging" ]; then                                                                                     
        percent=$(printf "%s" "${BatteryStat}" | grep percentage: | sed "s/[[:space:]]\+percentage:[[:space:]]\+//;s/%//")       
        if [ ${percent} -lt ${criticalLevel} ]; then                                                                             
            loginctl hibernate                                                                                                   
        fi                                                                                                                       
    fi                                                                                                                           
done                   
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum