mirror of
https://github.com/alyraffauf/nixcfg.git
synced 2024-11-22 16:23:55 -05:00
19 lines
469 B
Bash
19 lines
469 B
Bash
|
#!/usr/bin/env bash
|
||
|
|
||
|
if [ -d /sys/class/power_supply/BAT0 ]; then
|
||
|
BAT=/sys/class/power_supply/BAT0
|
||
|
elif [ -d /sys/class/power_supply/BAT1 ]; then
|
||
|
BAT=/sys/class/power_supply/BAT1
|
||
|
else
|
||
|
echo "No battery found."
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
CRIT=''${1:-10}
|
||
|
STAT=$(cat $BAT/status)
|
||
|
PERC=$(cat $BAT/capacity)
|
||
|
|
||
|
if [[ $PERC -le $CRIT ]] && [[ $STAT == "Discharging" ]]; then
|
||
|
notify-send --urgency=critical --icon=dialog-error "Battery Critical" "Current charge: $PERC%".
|
||
|
fi
|