I'd like a debian laptop with LXDE to do a system beep every 10 or 30 seconds once the battery reaches a critical level. is that possible?


Yes, it is possible. One way is listening for udev events when the battery level changes, and comparing it against a threshold. Otherwise, this is a quick and dirty way. Make a systemd service to start this in the background at boot and you'll get beeps every 10 seconds once your battery level drops below 5%.


let PERIOD=10

exec 3>&2
exec 2>/dev/null

while true; do
  level=$(acpi -b | grep -oP '\d+(?=%)')
  if [ $level -lt $CRIT_BATT_LVL ]; then
    timeout -k 0.75s 0.5s speaker-test --frequency 2000 --test sine >/dev/null
  sleep $PERIOD

exec 2>&3
exec 3>&-

The beeps will sound through your speakers. Make sure they aren't muted. If you want a beep through a motherboard speaker, look into the beep utility.

  • 1
    Also you need to check the charging status if acpi -b | grep Discharging; then ... , to stop beeping while charging. – GAD3R Mar 10 '20 at 15:03
  • Generalized this and systemd/udev rules into a gist – Akom May 5 at 15:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.