Mailinglist Archive: opensuse-factory (331 mails)

< Previous Next >
Re: [opensuse-factory] TW auto suspend on low battery level
On 2017-09-03 21:59, Marco Calistri wrote:
Hello,

During time I lost the benefits of having a working automatic suspend or
hibernate function on my laptop for a certain level of low battery
percentage.

...

So I decided to Google and finally I found a perfectly working
alternative; I just tested on my Tumbleweed and it works perfectly.

...

1) put this script in your /usr/local/bin and set execution permission:

/usr/local/binlowbattcheck.sh

Probably /usr/local/sbin would be more appropriate.

...

It starts _only_ if your power supply is not plugged and if the battery
capacity goes below 5%

2) create this systemd.service and enable it:

/etc/systemd/system/lowbatt.service

[Unit]
Description=Low Battery Auto-Suspend

[Service]
Type=simple
RestartSec=60
Restart=always
ExecStart=/usr/local/bin/lowbattcheck.sh

[Install]
WantedBy=multi-user.target

sudo systemctl start lowbatt.service

There is a catch.

This thing just runs a script every minute, similar to a cron job. It
will cause the hard disk to be used once per minute, so the disk will
never go to sleep, will keep rotating full time.


It would be perhaps better a script that does the test on its own,
looping every minute, always loaded. And probably better if it is a binary.


Now you have a 100% working auto-suspend for your laptop when battery
capacity is = or lower than 5%

Of course you can choice different percentage as well as replace
systemctl suspend with systemctl hibernate, hybrid-sleep, if you prefer.

I have found that these are not reliable. Some times the procedure
aborts, but the screensaver may have kicked in so you never know that it
failed unless you wonder and look.

Other times the procedure takes minutes to complete, doing I don't know
what.

Both are dangerous situations with a low battery.

--
Cheers / Saludos,

Carlos E. R.
(from 42.2 x86_64 "Malachite" at Telcontar)

< Previous Next >
References