]> git.cameronkatri.com Git - dotfiles.git/blob - .local/bin/bat-check
Update
[dotfiles.git] / .local / bin / bat-check
1 #!/bin/sh
2 #
3 # ISC License
4 #
5 # Copyright (c) 2020-2021, Jake Bauer
6 #
7 # Permission to use, copy, modify, and/or distribute this software for any
8 # purpose with or without fee is hereby granted, provided that the above
9 # copyright notice and this permission notice appear in all copies.
10 #
11 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 #
19
20 while true; do
21 perc=$(apm -l)
22 ac=$(apm -a)
23 if [ ! "$ac" -eq 1 ]; then
24 if [ "$perc" -lt 10 ]; then
25 notify-send -u critical "CRITICAL: Battery Drained" \
26 "Hibernating soon!"
27 elif [ "$perc" -lt 15 ]; then
28 notify-send -u critical "WARNING: Battery Critically Low" \
29 "Plug in a charger now or save all work and shut down."
30 elif [ "$perc" -lt 20 ]; then
31 notify-send "Warning: Battery Low" "Plug in a charger soon."
32 fi
33 fi
34 sleep 300
35 done