diff options
| author | Aargh Rai <aargh.rai+git@gmail.com> | 2025-09-25 10:53:09 +0530 |
|---|---|---|
| committer | Aargh Rai <aargh.rai+git@gmail.com> | 2025-09-25 10:53:09 +0530 |
| commit | a65f1cc093887dd9276af2a332b2cee0b9c67241 (patch) | |
| tree | cece2fd925834f3c292680c8a208a7fe893fb356 | |
| parent | 9c4bc6622794e289ebd98ad1217bfe531dd781d6 (diff) | |
batter notification fixed
| -rw-r--r-- | hypr/battery-notif.sh | 18 | ||||
| -rw-r--r-- | hypr/battery_warning.py | 18 | ||||
| -rw-r--r-- | waybar/battery_high.png | bin | 1111 -> 0 bytes |
3 files changed, 16 insertions, 20 deletions
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 Binary files differdeleted file mode 100644 index 0e4d8c5..0000000 --- a/waybar/battery_high.png +++ /dev/null |
