From 6844394d4e77bf13b7662c8129cb6b37fbbdd56f Mon Sep 17 00:00:00 2001 From: InigoGutierrez Date: Tue, 16 Apr 2019 12:27:11 +0200 Subject: i3battery.sh now sends a notification when battery is too low. --- i3blocks/i3battery.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/i3blocks/i3battery.sh b/i3blocks/i3battery.sh index d6acda6..b7441d1 100755 --- a/i3blocks/i3battery.sh +++ b/i3blocks/i3battery.sh @@ -11,8 +11,9 @@ case $BLOCK_BUTTON in - Text color reflects charge left" ;; esac -capacity=$(cat /sys/class/power_supply/"$1"/capacity) || exit status=$(cat /sys/class/power_supply/"$1"/status) +capacity=$(cat /sys/class/power_supply/"$1"/capacity) || exit +remaining=$(acpi | cut -d' ' -f5 | cut -d':' -f-2) if [ "$capacity" -ge 80 ]; then color="#b8bb26" @@ -24,14 +25,13 @@ elif [ "$capacity" -ge 10 ]; then color="#fe8019" else color="#fb4934" - [ "$status" != "Charging" ] && warn="❗" + [ "$status" != "Charging" ] && warn="❗" && dunstify -u critical -r "$(dunstifyIDs.sh "batteryLow")" "Battery remaining: $capacity% ($remaining)" fi [ -z "$warn" ] && warn="" [ "$status" = "Charging" ] && color="#1fffaf" -remaining=$(acpi | cut -d' ' -f5 | cut -d':' -f-2) printf "%s%s%s (%s)" "$color" "$(echo "$status" | sed -e "s/,//g;s/Discharging/🔋/;s/Charging/🔌/;s/Unknown/♻️/;s/Full/⚡/;s/ 0*/ /g;s/ :/ /g")" "$warn" "$(echo "$capacity" | sed -e 's/$/%/')" "$remaining" echo "" -- cgit v1.2.1