Shop Forum More Submit  Join Login
Battery Warning by thesaiful Battery Warning by thesaiful
Battery Warning for Ubuntu / Linux Mint

Hi,
This is my small creation of low battery notifications and full battery notification. Now you can see a battery notification Window in your linux desktop.

How to Install
- Download file here
- Extract downloaded file. There are 5 hidden files, to show them press Ctrl + H your keyboard
- Copy the 5 files to your home directory
- Create a StartUp program that run ".batterywarning.sh" file
- Done!

Notes :
You can specify the battery level to warn by editing ".batterywarning.sh" file
Preview see here goo.gl/kAeHl7
:iconamosbatto:
amosbatto Featured By Owner Edited May 25, 2018
In Debian Jessie with a laptop that has two batteries, I had to do the following to get this to work:
#!/bin/bash

    while true
    do
        export DISPLAY=:0.0
        battery1_level=`acpi -b | grep -P -o -m 1 '[0-9]+(?=%)'`
        battery2_level=`acpi -b | grep -P -o  '[0-9]+(?=%)' | sed -n 2p`
        battery_level_added=$(( battery1_level + battery2_level ))
        battery_level=$(( battery_level_added / 2 ))
        ac_power=`acpi -a | grep -P -o  '(on|off)'`
       
        if [ "$ac_power" = "on" ]; then
            if [ $battery_level -ge 90 ]; then
                notify-send -t 20000 "Battery charging above 90%. Unplug your AC adapter!" "Charging: ${battery_level}% "
                java -jar /home/amos/batteryAlert/.batt_full.jar   ## Display FULLBATTERY notification window
            fi
        else  #if discharging battery
            if [ $battery_level -le 10 ]; then
                notify-send -t 30000 "Battery is lower than 10%. Connect your AC adapter." "Charging: ${battery_level}%"
                java -jar /home/amos/batteryAlert/.batt_low.jar   ## Display LOWBATTERY notification window
            fi
        fi

        sleep 180 # run once every 3 minutes
    done

(doing math in bash really sucks!)

Also I had to install the following packages:
apt install notify-osd libnotify-bin
apt install -t jessie-backports ca-certificates-java openjdk-7-jre

Hope this helps other people.
Reply
:iconyanbaong:
YanBaong Featured By Owner Edited Apr 18, 2017
can i download and use this app bro or share it? thank you, please relpy my comment to know if you let me use it
Reply
Add a Comment:
 
×


Details

Submitted on
July 13, 2015
File Size
28.4 KB
Link
Thumb

Stats

Views
1,786
Favourites
2 (who?)
Comments
2
Downloads
252
×