Good morning,
I'm using the latest vanilla kernel.
I tested @luca219 script and it's not working...
1. The email is sent properly but the poweroff does not work. I initially thought the system was rebooting quickly but it's not the case. The script is ran by root's crontab so it should be able to poweroff. I edited the script to send a 2nd email after the poweroff and both emails are sent so the script has not crashed and the poweroff came back to the script.
2. Ignoring the poweroff issue for now, I went on and continued to another test... If I drain the battery to under 20%, the script sends an email every 10 minutes as per the cron; if I reconnect the power supply, I still get an email every 10 minutes until battery reaches 20%. But the problem is the script would trigger a poweroff when the system would reboot when the power comes back. In other words, the script needs to check if running on battery or power; if running on power, the script should not poweroff.
Thank you.