diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2019-11-13 23:34:30 +0100 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2019-11-13 23:34:30 +0100 |
commit | 93466218ccddb3a10406ce7c5f09e07de2e6d6ff (patch) | |
tree | 818e08df9a1808d8520a45cd243d2fcee57e91cb | |
download | lowbat-gnu-93466218ccddb3a10406ce7c5f09e07de2e6d6ff.tar.gz lowbat-gnu-93466218ccddb3a10406ce7c5f09e07de2e6d6ff.tar.bz2 lowbat-gnu-93466218ccddb3a10406ce7c5f09e07de2e6d6ff.tar.xz lowbat-gnu-93466218ccddb3a10406ce7c5f09e07de2e6d6ff.tar.zst lowbat-gnu-93466218ccddb3a10406ce7c5f09e07de2e6d6ff.zip |
First commit
-rw-r--r-- | Makefile | 2 | ||||
-rwxr-xr-x | bin/lowbat | 21 |
2 files changed, 23 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..6d8b5af --- /dev/null +++ b/Makefile @@ -0,0 +1,2 @@ + +SRCS diff --git a/bin/lowbat b/bin/lowbat new file mode 100755 index 0000000..0fde1e6 --- /dev/null +++ b/bin/lowbat @@ -0,0 +1,21 @@ +#!/bin/bash + +notify() { + notify-send "Low battery" "Please plug in computer" -u critical -t 15000 + echo "beep beep - low battery" | espeak +} + +while [ 1 ]; do + acstat=$(acpi | awk '{print $3}' | rev | cut -c 2- | rev) + batlvl=$(acpi | awk '{print $4}' | rev | cut -c 3- | rev) + while [[ $acstat == "Discharging" && $batlvl -lt 25 ]]; do + $(notify) + sleep 20 + acstat=$(acpi | awk '{print $3}' | rev | cut -c 2- | rev) + batlvl=$(acpi | awk '{print $4}' | rev | cut -c 3- | rev) + if [[ $acstat == "Charging" ]]; then + break + fi + done + sleep 240 +done |