aboutsummaryrefslogtreecommitdiff
path: root/hypr/battery-notif.sh
blob: e64442a190f6bb9f4bf16e7ed3df340603253de2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/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 "Very Low Battery" -i ~/.config/hypr/battery/battery_critical.png -t 5000
    elif [[ battery -lt 31 ]]; then
      notify-send -u normal "Low Battery" -i ~/.config/hypr/battery/battery_low.png -t 5000
    fi
  fi
  pid=$!
  sleep 5
  kill $pid
done