summaryrefslogtreecommitdiff
path: root/qubes-dwm-6.2/scripts/battery_monitor
blob: 41d916f674cc29574d585784f7d884aa170553b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/bin/sh

state="$HOME/.battery_warned"

if [ -f "$state" ]; then
  rm "$state"
fi

while true; do
  perc="$(acpi | awk 'BEGIN { IFS="," } /Battery 0: Discharging/ { print(substr($4,0,length($4)-2)) }')"
  if [ -n "$perc" ]; then 
    if [[ "$perc" < "20" ]] && [[ ! -f "$state" ]]; then
      notify-send -u critical "Battery low! $perc%"      
      touch "$state"
    fi
  fi
  sleep 60s
done