3

Can the low battery notification's look and feel be made clearer? The default notification is very small. So sometimes, we do not even notice that notification and the laptop shuts down.

So, how can I change the look and feel for only the low battery notifications?

pomsky
  • 68,507

1 Answers1

4

I am not sure how easy it is to tinker only the low battery alert notification, but you can manually set up a slightly better notification system for yourself following this hacky workaround:

  1. First you'll need to install acpi by running

    sudo apt install acpi
    
  2. Next you need to create a bash script. Create an empty text file, say battery-alert.sh and add the following lines

    #!/bin/bash
    while true
        do
            export DISPLAY=:0.0
            battery_level=`acpi -b | grep -P -o '[0-9]+(?=%)'`
            if on_ac_power; then                           #check if AC is plugged in
                    :
            else
                 if [ $battery_level -le 5 ]; then         #check if the battery level is below 5%, change the number after "-le" to set your preferred battery level
                    notify-send -u critical "Low Battery!" "Please plug your AC adapter, battery level: ${battery_level}%" -i battery-caution
                 fi
            fi
    sleep 300                                              #wait for 300 seconds before checking again, change the number after "sleep" to set your preferred waiting period
    done
    
  3. Save the file.

  4. Make the script executable and run it. You'll get a persistent notification (you'll have to click it to dismiss it) if the battery level is below 5%.

You may also consider adding the script to your startup applications so that it starts automatically every time you boot your laptop.

pomsky
  • 68,507