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.

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

| improve this answer | |
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

| improve this answer | |
  • is there a possibility that we can make a notification for a battery that is full? – Ahmad Shiddiq Mar 22 '19 at 18:06
  • @AhmadShiddiq: Maybe this helps? – Miguel Arduz Mar 24 '19 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

| improve this answer | |

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.