2

How to make notification when battery is low 15%-10% and how to make notification when battery already full in charge?

Thanks in advance.

3 Answers 3

1

I have written a custom script that will do as shown below:

enter image description here


Script:

#!/usr/bin/env bash
while true
do
    export DISPLAY=:0.0
    battery_percent=$(acpi -b | grep -P -o '[0-9]+(?=%)')
    if on_ac_power; then
        if [ "$battery_percent" -gt 98 ]; then
            notify-send --app-name=battery "Battery full." "Level: ${battery_percent}% "
        fi
    else
        if [ "$battery_percent" -lt 15 ]; then
            notify-send --app-name=battery "Battery low." "Level: ${battery_percent}% "
        elif [ "$battery_percent" -lt 10 ]; then
            notify-send --app-name=battery "Battery Critical." "Level: ${battery_percent}% "
        fi
    fi
    sleep 300 # (5 minutes)
done

Installation:

Run:

sudo apt install acpi

Save above script as "battery_notification.sh" under "/usr/local/bin"

sudo chmod +x /usr/local/bin/battery_notification.sh

Run Script at start-up:

Open System Setting -> Applications -> Startup

  • Click Add
  • Enter full path /usr/local/bin/battery_notification.sh

enter image description here

0

I was searching for the same thing. Here I found a solution to get notifications for low and critically low battery state: Battery notifications

2
  • is there a possibility that we can make a notification for a battery that is full? Mar 22, 2019 at 18:06
  • @AhmadShiddiq: Maybe this helps? Mar 24, 2019 at 14:21
0

For the second part of your question

...make notification when battery already full in charge?

You can follow this answer here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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