Suitable for laptops that don't generate udev events when battery charge level changes (but do generate events when unplugged).
Uses MP3 files (use mine or make your own).
You can also change sound()
to use a tone as in this example
- Copy MP3 files to
/usr/local/bin
(or change the shell script) - Copy other files to the location specified at the top (change "CHANGE_TO_MY_USER" to the username you primarily use)
- Run the following (to make udev and systemd aware of new config):
chmod a+x /usr/local/bin/battery-warning.sh
systemctl daemon reload
systemctl enable battery-warning
systemctl start battery-warning
systemctl reload udev
- Now:
- Pull the plug and you should hear a sound
- Plug it back in and you should hear a sound
- Let the battery discharge below THRESHOLD and you should hear a sound every SLEEP interval