X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=system-status;h=47d0a6753e7d6612989043dcbc82ccd664e69627;hb=51c8b40fd2aac71d29dc9298ca65425725ad1edd;hp=28b302441684782b49f838b50512b6c13912eca9;hpb=523b7ff889aaafdcd997d84b2a06744993018e89;p=distro-setup diff --git a/system-status b/system-status index 28b3024..47d0a67 100755 --- a/system-status +++ b/system-status @@ -13,7 +13,7 @@ if [[ $EUID != 1000 ]]; then exit 1 fi -source /a/bin/errhandle/err +source /a/bin/bash-bear-trap/bash-bear status_file=/dev/shm/iank-status shopt -s nullglob @@ -443,6 +443,7 @@ if [[ $1 ]]; then exit 0 fi +loop_count=0 main-loop() { while true; do power=true @@ -450,16 +451,29 @@ main-loop() { power=false fi wait=15 - if ! $power; then - if systemctl -q is-active bitcoind; then - bitcoinoff + + if $power; then + if (( loop_count % 10 == 0 )); then + if [[ -r /sys/class/power_supply/BAT0/capacity ]]; then + bat=$(cat /sys/class/power_supply/BAT0/capacity) + else + bat=100 + fi + case $bat in + 100|9?) + bitcoinon & + ;; + esac fi + else + bitcoinoff wait=60 fi sleep $wait write-status mute + loop_count=$(( loop_count + 1 )) done }