aboutsummaryrefslogtreecommitdiff
path: root/scripts/battery_notif.sh
blob: e5f44e96418435950bb5ec615eb429a0584ce948 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/usr/bin/env bash
while true; do
  status=$(cat /sys/class/power_supply/BAT1/status)
  if [[ "$status" = "Discharging" ]]; then
    battery=$(cat /sys/class/power_supply/BAT1/capacity)
    if [[ battery -lt 16 ]]; then
      notify-send -u critical "CHARGE" "Very Low Battery" -t 2000
    elif [[ battery -lt 31 ]]; then
      notify-send -u normal "CHARGE" "Low Battery" -t 2000
    fi
  fi
  pid=$!
  sleep 2
  kill $pid
done