repaired the battery notification warnings

This commit is contained in:
Tomas Rivera
2026-03-28 18:01:59 +01:00
parent 8a04ab0e9c
commit 16c76a53e4
3 changed files with 38 additions and 48 deletions
+2 -2
View File
@@ -38,8 +38,8 @@ in
# Runs full time in background # Runs full time in background
x=0 x=0
while true; do while true; do
Battery_Status="$(cat /sys/class/power_supply/BAT*/status)" Battery_Status="$(\cat /sys/class/power_supply/BAT*/status)"
Battery_Capacity=$(cat /sys/class/power_supply/BAT*/capacity) Battery_Capacity=$(\cat /sys/class/power_supply/BAT*/capacity)
case "$Battery_Status" in case "$Battery_Status" in
"Discharging") "Discharging")
+13 -22
View File
@@ -1,13 +1,13 @@
# taken and adapted https://github.com/miniMinn24/Battery_Notify with MIT License # taken and adapted https://github.com/miniMinn24/Battery_Notify with MIT License
{ {
writeShellApplication, writeShellApplication,
mplayer, mplayer,
brightnessctl, brightnessctl,
... ...
}: let }: let
NotifySound = ../../assets/battery_notify.mp3; NotifySound = ../../assets/battery_notify.mp3;
in in
writeShellApplication { writeShellApplication {
name = "custom-batterywarning"; name = "custom-batterywarning";
runtimeInputs = [ runtimeInputs = [
mplayer mplayer
@@ -18,40 +18,31 @@ in
# Delay for startup # Delay for startup
sleep 5 sleep 5
# Change your sound path here
playsound() { playsound() {
mplayer ${NotifySound} mplayer ${NotifySound}
} }
sendNotification() {
local message="$1"
notify-send -h string:x-canonical-private-synchronous:sys-notify -e -u critical "Battery Low!" "$message"
}
notify_count=0
while true; do while true; do
Battery_Status="$(cat /sys/class/power_supply/BAT*/status)" Battery_Status="$(cat /sys/class/power_supply/BAT*/status)"
Battery_Capacity=$(cat /sys/class/power_supply/BAT*/capacity) Battery_Capacity="$(cat /sys/class/power_supply/BAT*/capacity)"
if [ "$Battery_Status" == "Discharging" ] && [ "$Battery_Capacity" -le 14 ]; then if [ "$Battery_Status" == "Discharging" ]; then
if [ "$notify_count" -eq 0 ]; then if [ "$Battery_Capacity" -le 20 ] && [ "$Battery_Capacity" -ge 10 ]; then
sendNotification "Power running out: <b>''${Battery_Capacity}%</b>" notify-send -e -u critical "Battery Low!" "Power running out: <b>''${Battery_Capacity}%</b>"
playsound playsound
notify_count=$((notify_count + 1))
sleep 180 sleep 180
elif [ "$notify_count" -eq 1 ]; then elif [ "$Battery_Capacity" -lt 10 ]; then
sendNotification "<b>Save your works</b> before immediate shutdown." notify-send -e -u critical "Battery Low!" "<b>Save your works</b> before immediate shutdown."
playsound playsound
notify_count=$((notify_count - 1))
sleep 180 sleep 180
fi fi
else else
notify_count=0
sleep 120 sleep 120
fi fi
done done
''; '';
} }
-1
View File
@@ -9,7 +9,6 @@ tor.x86_64
torbrowser-launcher.noarch torbrowser-launcher.noarch
maybe configure a bit ripgrep? majuscules maybe configure a bit ripgrep? majuscules
the battery notification is broken
why frameworktooltui settings dont apply? why frameworktooltui settings dont apply?