commit 31abf611a9b7c0fa5ea64094cf4165f74163d0d1 parent c78adc92e2c3e8e5e89693079cfaa37db0789d3a Author: Jake Bauer <jbauer@paritybit.ca> Date: Thu, 20 May 2021 23:50:34 -0400 Replace battery notification script Diffstat:
A | .local/bin/batcheck | | | 23 | +++++++++++++++++++++++ |
D | .local/bin/battery-notify | | | 21 | --------------------- |
2 files changed, 23 insertions(+), 21 deletions(-)
diff --git a/.local/bin/batcheck b/.local/bin/batcheck @@ -0,0 +1,23 @@ +#!/bin/sh + +if [ "$1" = "-p" ]; then + echo $(apm -l) $(apm -a) > ~/.local/share/battery_percent + exit +fi + +while true; do + perc=$(cat ~/.local/share/battery_percent | cut -d' ' -f1) + ac=$(cat ~/.local/share/battery_percent | cut -d' ' -f2) + if [ ! "$ac" -eq 1 ]; then + if [ "$perc" -lt 10 ]; then + notify-send -u critical "CRITICAL: Battery Drained" \ + "Hibernating soon!" + elif [ "$perc" -lt 15 ]; then + notify-send -u critical "WARNING: Battery Critically Low" \ + "Plug in a charger now or save all work and shut down." + elif [ "$perc" -lt 20 ]; then + notify-send "Warning: Battery Low" "Plug in a charger soon." + fi + fi + sleep 300 +done diff --git a/.local/bin/battery-notify b/.local/bin/battery-notify @@ -1,21 +0,0 @@ -#!/bin/sh - -get_percentage_BAT0() -{ - acpi | head -1 | cut -d' ' -f4 | tr -d '%,' -} - -# get_percentage_BAT1() -# { -# acpi | tail -1 | cut -d' ' -f4 | tr -d '%,' -# } - -pcent=$(get_percentage_BAT0) -[ "$pcent" -eq 10 ] && notify-send -u critical -i battery-caution-symbolic \ - "Battery Low" "Please plug in charger" -[ "$pcent" -lt 5 ] && notify-send -u critical -i battery-empty-symbolic \ - "Battery Critically Low" "Save all work or plug in charger now" - -# pcent=$(get_percentage_BAT1) -# [ "$pcent" -eq 10 ]; notify-send -u critical -i battery-low-symbolic \ -# "External Battery Low" "Switching to internal battery soon"