diff --git a/files/scripts/battery_nag.sh b/files/scripts/battery_nag.sh index ab25f76..073168e 100755 --- a/files/scripts/battery_nag.sh +++ b/files/scripts/battery_nag.sh @@ -6,10 +6,9 @@ echo "`date` - Checking Active Programs" -PID="$$" -ps -ef | grep battery_nag.sh | grep -v grep | grep -v killall | grep -v $$ +ps -ef | grep battery_nag.sh | grep -v grep | grep -v "sh -c" | grep -v kill | grep -v $$ -active=`ps -ef | grep battery_nag.sh | grep -v grep | grep -v killall | grep -vc $$` +active=`ps -ef | grep battery_nag.sh | grep -v grep | grep -v "sh -c" | grep -v kill | grep -vc $$` if (( "$active" >= 1 )); then echo "Program already running, exiting. Number of processes: $active" exit 1 @@ -97,7 +96,9 @@ while true; do fi time=$sleep - if [[ "$accelerate" == "Y" ]]; then + if [[ "$accelerate" == "Y" && $batt -lt $alert ]]; then + # Bash only returns whole numbers, so things like 20/11 only provide 1. + # Likewise, if the battery is full, 20/100 returns 0, which is bad. :) if (( batt > 0 )); then time=$(( time / (alert / batt) )) else diff --git a/files/settings/i3.config b/files/settings/i3.config index f296c97..38ab13b 100644 --- a/files/settings/i3.config +++ b/files/settings/i3.config @@ -380,4 +380,4 @@ exec_always --no-startup-id feh --recursive --randomize --bg-fill ~/Pictures/Wal exec_always --no-startup-id "killall picom; picom -f" # Battery -exec_always --no-startup-id "pkill -f battery_nag.sh; battery_nag.sh >~/Reports/battery_nag.log 2>&1" +exec_always --no-startup-id bash -c 'pkill -ef "bash `which battery_nag.sh`" >~/Reports/battery_nag.log 2>&1; battery_nag.sh >>~/Reports/battery_nag.log 2>&1'