Pi66

Home | Repos | About | Blog | Gaza

pino-rs
Rust notification daemon.
git clone https://git.pi66.xyz/pino-rs

About | Files | Commits | Refs | License


Add some usefull monitoring scripts

Author: pixel
Date: 2025-04-15 21:55
commit: 0358bcca

Stat

M scripts/battery-monitor.sh 8 +1 -7

Diff

diff --git a/scripts/battery-monitor.sh b/scripts/battery-monitor.sh
index c642220..11dd259 100755
--- a/scripts/battery-monitor.sh
+++ b/scripts/battery-monitor.sh
@@ -1,11 +1,9 @@
 #!/bin/bash

-# Battery Monitor - Fixed and Optimized UP_THRESHOLD=90 DOWN_THRESHOLD=20 CHECK_INTERVAL=0.3

-# Find battery path (more reliable method) BATTERY_PATH=$(find /sys/class/power_supply/ -name "BAT*" | head -1) AC_PATH=$(find /sys/class/power_supply/ -name "AC*" | head -1) [ -z "$BATTERY_PATH" ] && echo "No battery found" && exit 1 @@ -17,19 +15,15 @@ while true; do level=$(cat "$BATTERY_PATH/capacity") ac_status=$(cat "$AC_PATH/online" 2>/dev/null || echo "0")

...
Show all
diff --git a/scripts/battery-monitor.sh b/scripts/battery-monitor.sh
index c642220..11dd259 100755
--- a/scripts/battery-monitor.sh
+++ b/scripts/battery-monitor.sh
@@ -1,11 +1,9 @@
 #!/bin/bash

-# Battery Monitor - Fixed and Optimized UP_THRESHOLD=90 DOWN_THRESHOLD=20 CHECK_INTERVAL=0.3

-# Find battery path (more reliable method) BATTERY_PATH=$(find /sys/class/power_supply/ -name "BAT*" | head -1) AC_PATH=$(find /sys/class/power_supply/ -name "AC*" | head -1) [ -z "$BATTERY_PATH" ] && echo "No battery found" && exit 1 @@ -17,19 +15,15 @@ while true; do level=$(cat "$BATTERY_PATH/capacity") ac_status=$(cat "$AC_PATH/online" 2>/dev/null || echo "0")

- # 1. Plug detection (AC status changed from 0 to 1) if [ "$ac_status" -eq 1 ] && [ "$last_ac_status" -eq 0 ]; then pino -t "Plugged In" -m "Now charging ($level%)" -d 5 - - # 2. Unplug detection (AC status changed from 1 to 0) + elif [ "$ac_status" -eq 0 ] && [ "$last_ac_status" -eq 1 ]; then pino -t "Unplugged" -m "On battery ($level%)" -d 5

- # 3. Crossed above 90% (only when discharging) elif [ "$level" -ge $UP_THRESHOLD ] && [ "$last_level" -lt $UP_THRESHOLD ] && [ "$ac_status" -eq 0 ]; then pino -t "Battery High" -m "Reached $level%" -d 5

- # 4. Crossed below 20% (only when discharging) elif [ "$level" -le $DOWN_THRESHOLD ] && [ "$last_level" -gt $DOWN_THRESHOLD ] && [ "$ac_status" -eq 0 ]; then pino -t "Battery Low" -m "Only $level% left" -d 5 fi

// Created by Pi66

// Copyright ©Pi66 2026