From 1c58ccb7855719483490abe1982afa12b0488f24 Mon Sep 17 00:00:00 2001 From: Jack Jamison Date: Fri, 15 May 2026 22:36:21 -0400 Subject: refactor and battery notifier --- scripts/system/monitor-battery | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 scripts/system/monitor-battery (limited to 'scripts/system/monitor-battery') 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 -- cgit v1.2.3