No user feedbak when booting a laptop with almost empty battery

Currently, when the battery inside a laptop running Fedora reaches almost empty e.g. 2% an automatic shutdown is initiated to (presumably) prevent a potential hard power off due to the low battery later. I’m not quite shore what piece of software initiates this (presumably either gnome-shell/GDM or systemd) but it’s a desirable behaver that’s fine when an already booted laptop reaches a low battery state.

But if a laptop with quite a low battery is off and then turned on, currently it will proceed through the entire boot process only for GDM to flicker for a moment and then immediately shutdown again due to the low battery. This is quite confusing if say the laptop is connected to a charger, but the charger is loose in the socket and is not actually providing charge. In that case, the full boot up, GDM flicker, and subsequent shutdown might be quite hard to understand as being caused by low battery.

Would it be possible for the status of the laptop battery to be checked early in the boot process and subsequently for the boot process to be halted and an icon or graphic in Plymouth indicating low battery to show for a moment e.g. 10 seconds and then to proceed to a shutdown? Kind of similar to what Android and IOS currently do (although their graphics are displayed by their equivalent of a BIOS/firmware and not the OS).

While this may not be specific to Fedora, so far I’ve only tested it with a laptop running Fedora, and any solution would presumably involve configuring multiple components of the boot process to achieve what I described here, so this post wouldn’t be specific to any one project’s issue tracker. If this post were better suited on another discussion board, please direct me there!

2 Likes

systemd includes the check that you describe, see systemd-battery-check.service. In Fedora we use dracut, which seems to have a module for it. Maybe this module needs to be enabled.

I’ll ask some dracut maintainers to chime in here.

2 Likes

Sure, makes sense - we just need to include the module here (set to return 0). But it’ll come with next Fedora in case it fails in any case (there’s no way to recover initrd build from that).

1 Like

The module is in unreleased dracut still, but from version 105, which I’m just working on, it will be in rawhide.

To test it on stable Fedora, you can try installing it from my COPR: https://copr.fedorainfracloud.org/coprs/pvalena/dracut

1 Like