From 7605593b815805c268edf4c3e9dc8ab2c55456da Mon Sep 17 00:00:00 2001 From: "tanguy@aristotle" Date: Sun, 2 Aug 2020 16:05:04 +0200 Subject: [PATCH] Add low battery script for notificatio nusing cron job --- .config/cron/battery_notifier.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100755 .config/cron/battery_notifier.sh diff --git a/.config/cron/battery_notifier.sh b/.config/cron/battery_notifier.sh new file mode 100755 index 0000000..ffbf911 --- /dev/null +++ b/.config/cron/battery_notifier.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +battery_level=$(acpi -b | grep -P -o -m1 "[0-9]+(?=%)") + +if [ $battery_level -le 5 ] +then + /usr/bin/notify-send "Battery level critical" "Battery level critically low, plug to avoid shutdown" --urgency=critical + exit +fi + +if [ $battery_level -le 15 ] +then + /usr/bin/notify-send "Battery low" "Battery level dropped under 15%" + exit +fi +