From a65f1cc093887dd9276af2a332b2cee0b9c67241 Mon Sep 17 00:00:00 2001 From: Aargh Rai Date: Thu, 25 Sep 2025 10:53:09 +0530 Subject: batter notification fixed --- hypr/battery-notif.sh | 18 ++++++++++++++++-- hypr/battery_warning.py | 18 ------------------ waybar/battery_high.png | Bin 1111 -> 0 bytes 3 files changed, 16 insertions(+), 20 deletions(-) delete mode 100644 hypr/battery_warning.py delete mode 100644 waybar/battery_high.png diff --git a/hypr/battery-notif.sh b/hypr/battery-notif.sh index 5e477d8..4298192 100644 --- a/hypr/battery-notif.sh +++ b/hypr/battery-notif.sh @@ -1,2 +1,16 @@ -nix-env -iA nixpkgs.python3.psutil -python battery_warning.py +#!/usr/bin/env bash + +while true; do + status=$(cat /sys/class/power_supply/BAT1/status) + if [[ "$status" = "Discharging" ]]; then + battery=$(cat /sys/class/power_supply/BAT1/capacity) + if [[ battery -lt 15 ]]; then + notify-send -u critical Very Low Battery -i ~/.config/waybar/battery_low.png + elif [[ battery -lt 30 ]]; then + notify-send -u normal Low Battery -i ~/.config/waybar/battery_low.png + fi + fi + pid=$! + sleep 5 + kill $pid +done diff --git a/hypr/battery_warning.py b/hypr/battery_warning.py deleted file mode 100644 index 882e8dd..0000000 --- a/hypr/battery_warning.py +++ /dev/null @@ -1,18 +0,0 @@ -import psutil -import subprocess -import time - -WARNING_LEVEL = 30 -CRITICAL_LEVEL = 15 - -while True: - battery = psutil.sensors_battery() - percent = battery.percent - if battery.power_plugged: - pass # Optionally notify full - else: - if percent <= CRITICAL_LEVEL: - subprocess.run(['notify-send', '-u', 'critical', 'Very Low Battery', '-i', '/home/aargh/.config/waybar/battery_low.png']) - elif percent <= WARNING_LEVEL: - subprocess.run(['notify-send', '-u', 'normal', 'Low Battery', '-i', '/home/aargh/.config/waybar/battery_low.png']) - time.sleep(5) diff --git a/waybar/battery_high.png b/waybar/battery_high.png deleted file mode 100644 index 0e4d8c5..0000000 Binary files a/waybar/battery_high.png and /dev/null differ -- cgit v1.2.3