Mailinglist Archive: opensuse-factory (339 mails)

< Previous Next >
[opensuse-factory] TW auto suspend on low battery level
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.

I don't know which has been the root cause that broken auto-suspend, if
the abandon of pm-utils, systemd or kernel or whatsoever, the fact is
that nothing seems working anymore now also by attempting to reconfigure
DE power managers.

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

I'm posting here because opensuse-factory is currently the only one M.L.
I'm subscribed too.

Hope somebody else could have the necessity to have a working suspend
feature on low batt. on his laptop.

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

/usr/local/binlowbattcheck.sh

#!/bin/bash
if [ $(cat /sys/class/power_supply/ACAD/online) -eq 0 ] && [ $(cat
/sys/class/power_supply/BAT1/capacity) -lt 5 ]
then /usr/bin/systemctl suspend
fi

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

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.

Cheers,

--
Marco Calistri
Linux version : openSUSE Tumbleweed 20170830
Kernel: 4.12.10-3.gd79ffeb-default - Cinnamon 3.4.6
--
Marco Calistri
Linux version : openSUSE Tumbleweed 20170830
Kernel: 4.12.10-3.gd79ffeb-default - Cinnamon 3.4.6
N�����r��y隊Z)z{.���r�+�맲��r��z�^�ˬz��N�(�֜��^� ޭ隊Z)z{.���r�+��0�������Ǩ�
< Previous Next >