battery-notify

battery level notifier
git clone git://git.pyratebeard.net/battery-notify.git
Log | Files | Refs | README

commit e47cba2bfd81f7b06113d71614a7e896a2c26f93
parent b9a7ba4761afcf79e46e5fad8079e1fa76cbafaf
Author: pyratebeard <root@pyratebeard.net>
Date:   Tue,  5 Mar 2019 14:07:50 +0000

script to check battery percentage and notify if required

Diffstat:
Acheck-batt | 17+++++++++++++++++
1 file changed, 17 insertions(+), 0 deletions(-)

diff --git a/check-batt b/check-batt @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +BATTPERC=$(cat /sys/class/power_supply/BAT0/capacity) + +notify() { + level=$1 + msg=$2 + DISPLAY=:0 /usr/bin/dunstify -u "$level" "POWER" "$msg" +} + +if [[ $BATTPERC == 50 ]] ; then + notify "low" "battery is at 50%" +elif [[ $BATTPERC == 30 ]] ; then + notify "normal" "battery is at 30%" +elif [[ "$BATTPERC | sed -e :a -e 's/^.\{1\}$/0&/;ta'" < 10 ]] ; then + notify "critical" "battery is less than 10%" +fi