diff options
| author | Jack Jamison <jackqjamison@gmail.com> | 2026-05-15 22:36:21 -0400 |
|---|---|---|
| committer | Jack Jamison <jackqjamison@gmail.com> | 2026-05-15 22:36:21 -0400 |
| commit | 1c58ccb7855719483490abe1982afa12b0488f24 (patch) | |
| tree | d6d6f95477c743c1e2e8f4a64095d50cb491338c /scripts/system/monitor-battery | |
| parent | fbe17d51cc2d52261721a46ee54d5dc8f32db3eb (diff) | |
refactor and battery notifier
Diffstat (limited to 'scripts/system/monitor-battery')
| -rwxr-xr-x | scripts/system/monitor-battery | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/scripts/system/monitor-battery b/scripts/system/monitor-battery new file mode 100755 index 0000000..94b7365 --- /dev/null +++ b/scripts/system/monitor-battery @@ -0,0 +1,30 @@ +#!/bin/sh + +threshold=20 +very_low_threshold=10 + +amount="low" +prev_cap=100 + +while true; do + cap=$(cat /sys/class/power_supply/BAT0/capacity) + status=$(cat /sys/class/power_supply/BAT0/status) + + # when capacity changes + if [ $cap -ne $prev_cap ]; then + + # notify when drop under threshold + if [ $cap -lt $threshold ] && [ $prev_cap -ge $threshold ]; then + notify-send "Plug In" "Battery has fallen under $threshold%" + fi + + # notify every percent if very low + if [ $cap -le $very_low_threshold ] && [ $status -ne "Charging" ]; then + notify-send "BATTERY LOW" "Battery is at $bat%" + fi + + fi + + prev_cap=$cap + sleep 10 +done |
