07-20-2019, 12:14 PM
(This post was last modified: 07-20-2019, 12:20 PM by pkfpeters.
Edit Reason: Added extra info about sysfs axp chip.
)
Hi Seal,
Yes there is a very easy way. Just create a small script and use the following (sysfs) items:
Current battery power level in percentage 0-100% full
/sys/class/power_supply/battery/capacity
Indicating if we are operation on battery or power supply (Kernel AC power looks a bit strange, but it does mean the DC input)
0 = Battery, 1 = DC input (main power)
/sys/class/power_supply/ac/present
Use `shutdown 0` in your script to shutdown.
With the information above you should be able to create a small bash script checking the battery level in
order to do a safety fast shutdown. Or use a countdown (for example. 120 seconds) and wait for power
to come back so bufferring small power outages. Dont forget to put the jumper on battery and if your script
works well you should be able to handle power restores (during shutdown delay , complete shutdowns
and auto boot up when power restores.
And if you want a lot more information just take a look at the sysfs items in:
/sys/class/axppower/
You can get all sorts of information, like battery temperature, charge current, etc.
Yes there is a very easy way. Just create a small script and use the following (sysfs) items:
Current battery power level in percentage 0-100% full
/sys/class/power_supply/battery/capacity
Indicating if we are operation on battery or power supply (Kernel AC power looks a bit strange, but it does mean the DC input)
0 = Battery, 1 = DC input (main power)
/sys/class/power_supply/ac/present
Use `shutdown 0` in your script to shutdown.
With the information above you should be able to create a small bash script checking the battery level in
order to do a safety fast shutdown. Or use a countdown (for example. 120 seconds) and wait for power
to come back so bufferring small power outages. Dont forget to put the jumper on battery and if your script
works well you should be able to handle power restores (during shutdown delay , complete shutdowns
and auto boot up when power restores.
And if you want a lot more information just take a look at the sysfs items in:
/sys/class/axppower/
You can get all sorts of information, like battery temperature, charge current, etc.