From db605c6c984d9e3b140a60658ecc9d321a169342 Mon Sep 17 00:00:00 2001 From: devaine Date: Sat, 26 Apr 2025 13:32:10 -0500 Subject: [PATCH] fix: changing FULL_BATTERY value + add condition + var add mild fixes + additions --- notifs/battery | 4 +++- notifs/battery-status | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/notifs/battery b/notifs/battery index 6fb6c55..6038978 100755 --- a/notifs/battery +++ b/notifs/battery @@ -9,7 +9,7 @@ BATTERY=$(acpi | grep -vwE "(unavailable)" | grep -o '[0-9]' | head -n 1) # Daemon Constants WARNING_PERCENT=35 -FULL_PERCENT=99 +FULL_PERCENT=98 BAT_PERCENT=$(acpi -b | grep "Battery $BATTERY" | head -n 1 | grep -P -o "[0-9]+(?=%)") DISCHARGING_COUNT=$(acpi -b | grep "Battery $BATTERY" | grep -c "Discharging") NOTCHARGING_COUNT=$(acpi -b | grep "Battery $BATTERY" | grep "until" | grep -c "Not Charging") @@ -21,11 +21,13 @@ FULL_BAT_FILE=/tmp/battery_full battery-full() { notify-send "Battery Full" "Battery is fully charged!" -i "battery-full-charged" -r 9991 -t 5000 touch $FULL_BAT_FILE + rm -rf $LOW_BAT_FILE } battery-low() { notify-send "Low Battery" "${BAT_PERCENT}% of battery remaining." -u critical -i "battery-caution" -r 9991 touch $LOW_BAT_FILE + rm -rf $FULL_BAT_FILE } battery-normal() { diff --git a/notifs/battery-status b/notifs/battery-status index 5222e75..2acd9a1 100755 --- a/notifs/battery-status +++ b/notifs/battery-status @@ -1,10 +1,10 @@ #!/bin/bash BATTERY=$(acpi | grep -vwE "(unavailable)" | grep -o '[0-9]' | head -n 1) BAT_PERCENT=$(acpi -b | grep "Battery $BATTERY" | grep -P -o "[0-9]+(?=%)") -DISCHARGING_COUNT=$(acpi -b | grep "Battery $BATTERY" | grep "until" | grep -c "Discharging") -#NOTCHARGING_COUNT=$(acpi -b | head -n 1 | grep -c "Not Charging") +DISCHARGING_COUNT=$(acpi -b | grep "Battery $BATTERY" | grep -E "until|remaining" | grep -c "Discharging") +NOTCHARGING_COUNT=$(acpi -b | grep "Battery $BATTERY" | grep -c "Not Charging") -if [[ $DISCHARGING_COUNT -eq 0 ]]; then +if [[ $DISCHARGING_COUNT -eq 0 ]] || [[ $NOTCHARGING_COUNT -eq 1 ]]; then dunstify "Battery Status" "Battery is currently charging at ${BAT_PERCENT}%" -i "battery-level-50-charging-symbolic" -r 9991 -t 5000 else dunstify "Battery Status" "Battery is currently at ${BAT_PERCENT}%" -i "battery-level-50-symbolic" -r 9991 -t 5000