How to monitor power state on Linux (Ubuntu 22.10)

Hello folks,

I know this probably a bit of a n00b question, but I am trying to figure out how to monitor my laptop’s power state over time. I have tried powertop, but either I am not grasping how to use it for my use case, or it is not the right tool.

My main concern at the moment is the following: even if I manually send the laptop into suspension, the LED around the power button remains on. This has started since I upgraded to 22.10. While on 22.04, the LED would start pulsating slowly. How do I figure out whether the change has to do with a change in behavior of the LED or if something in the power management got borked?

Thanks!

It’s likely that in the upgrade from 22.04 to 22.10 the default suspend for mem_sleep got changed to “s2idle” instead of “deep”. You can check by typing in a terminal:

cat /sys/power/mem_sleep

If this does show:

[s2idle] deep

you can change it to “deep” by typing:

echo deep | sudo tee /sys/power/mem_sleep

If you then manually suspend the laptop again, the light should start pulsating.

If that fix works, to make it permanent you’ll need to add it to the kernel boot parameters, following something like this advice.

With “s2idle” the power button light stays on during suspend and doesn’t pulsate. Do note that a lot of folks have had good success with s2idle and the kernel boot parameter “nvme.noacpi=1” (see #3 in this section of the Linux battery life tuning OP; there’s also a link there to a more universal way of modifying kernel boot parameters). You should get similar or even better results in terms of battery drain during suspend compared to “deep” plus a faster response time when resuming.

In terms of monitoring tools, I think the Statistics function of the gnome-power-manager might be what you’re looking for, but I’m not that conversant in Ubuntu or Gnome matters.

Hope that helps.

Thanks, that clears things up. If I switch it to deep, the light does start pulsating. So that mystery is solved.

I already have the kernel boot parameter added to GRUB, so what I need to figure out now is if there is a noticeable difference between the two in terms of battery life.

Honestly, the biggest problem I have had with the suspension of the laptop is that sometimes I find it happily chugging along while in my backpack, and I never know if I forgot to suspend it, or if it came to life on its own.
This is also why it would be nice to have a way to see a log of the power states, to understand when and how the laptop suspends itself (i.e. does it go to sleep when I close the lid?).

Anyhow, this was really useful. Thanks again!