Debian 12 / Gnome / How to shutdown laptop after battery percentage crossed
from wolf@lemmy.zip to linux@lemmy.ml on 04 Oct 2024 09:48
https://lemmy.zip/post/23900491

Hello Linux community,

I need some help with shutting down my laptop when the battery reaches a low percentage.

I am using Debian 12 with the GNOME desktop. WARNING: Minimal installation with self selected packages.

What I want to achieve is, that the laptop just does a ‘halt -p’ or shuts itself down when the battery is below 20%.

What I did so far:

Any help/pointers for further help would be highly appreciated.

#linux

threaded - newest

fushuan@lemm.ee on 04 Oct 2024 09:56 next collapse

A bash script that checks the battery and if its below X runs shutdown -now ?

Then run it every minute with cron.

It’s not very elegant but it would work.

wolf@lemmy.zip on 04 Oct 2024 10:18 collapse

Thanks, that would be a valid approach and my last resort.

As you said, I hope someone knows a more elegant solution, though!

fushuan@lemm.ee on 04 Oct 2024 10:22 collapse

It’s also not dependant on any DE tool and won’t fuck up with any update that resets gnome configs. Trusty cron will prevail.

With proper directory management I wouldn’t call it that inelegant tbh.

dvb@lemmy.ml on 04 Oct 2024 10:31 next collapse

ArchWiki: Hibernate on low battery level

This approach uses udev, so you don’t have to constantly check the battery level by yourself.

[deleted] on 04 Oct 2024 11:37 next collapse

.

eugenia@lemmy.ml on 04 Oct 2024 12:57 collapse

Answer is here, it was posted the other day: lemmy.ml/post/20903038 Instead of beeping as that script does, you shut the PC down.

wolf@lemmy.zip on 04 Oct 2024 14:08 collapse

Thanks, this would indeed solve my problem. Still hoping for a better solution, but if everything else fails I’ll utilize it!