From 4d61a485a38f954948edde6b70b4e6888bb38747 Mon Sep 17 00:00:00 2001 From: Emil Miler Date: Tue, 8 Dec 2020 10:01:20 +0100 Subject: [PATCH] Initial commit --- batterycheck | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100755 batterycheck diff --git a/batterycheck b/batterycheck new file mode 100755 index 0000000..ae34ee5 --- /dev/null +++ b/batterycheck @@ -0,0 +1,12 @@ +#!/bin/sh -e + +limit=${1:-18} +acpi=$(acpi -b) +acpi_status=$(echo "$acpi" | awk -F ': |,' {'print $2'}) + +[ "$acpi_status" == "Discharging" ] && + acpi_value=$(echo "$acpi" | awk -F ", " {'print $2'} | sed 's/%//') && + [ "$acpi_value" -lt "$limit" ] && + export DISPLAY=:0.0 && + notify-send -u critical "Battery charge at $acpi_value%" +