mirror of
https://github.com/alyraffauf/nixcfg.git
synced 2024-11-25 12:31:55 -05:00
19 lines
469 B
Bash
Executable file
19 lines
469 B
Bash
Executable file
#!/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
|