From 86839947ac40bcb095ced8720536142476633ab9 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Mon, 5 Aug 2019 23:33:57 +0200 Subject: [PATCH] #707 added ups info to screen --- home.admin/00infoBlitz.sh | 12 +++++++++++- home.admin/config.scripts/blitz.ups.sh | 7 +++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/home.admin/00infoBlitz.sh b/home.admin/00infoBlitz.sh index e8ab6d1..b36dac7 100755 --- a/home.admin/00infoBlitz.sh +++ b/home.admin/00infoBlitz.sh @@ -15,6 +15,16 @@ color_purple='\033[0;35m' source /home/admin/raspiblitz.info 2>/dev/null source /mnt/hdd/raspiblitz.conf 2>/dev/null +# get UPS info +source <(/home/admin/config.scripts/blitz.ups.sh status) +upsInfo="" +if [ "${upsStatus}" = "ONLINE" ]; then + upsInfo="${color_gray}${upsBattery}" +fi +if [ "${upsStatus}" = "ONBATT" ]; then + upsInfo="${color_red}${upsBattery}" +fi + # check hostname if [ ${#hostname} -eq 0 ]; then hostname="raspiblitz"; fi @@ -287,7 +297,7 @@ printf " ${color_yellow} ${color_yellow} ${color_yellow} -${color_yellow} ${color_amber}%s ${color_green} ${ln_alias} +${color_yellow} ${color_amber}%s ${color_green} ${ln_alias} ${upsInfo} ${color_yellow} ${color_gray}${network} Fullnode + Lightning Network ${torInfo} ${color_yellow} ,/ ${color_yellow}%s ${color_yellow} ,'/ ${color_gray}%s, temp %s°C %s°F diff --git a/home.admin/config.scripts/blitz.ups.sh b/home.admin/config.scripts/blitz.ups.sh index d045cef..597b695 100644 --- a/home.admin/config.scripts/blitz.ups.sh +++ b/home.admin/config.scripts/blitz.ups.sh @@ -79,12 +79,11 @@ if [ "$1" = "status" ]; then if [ ${#status} -eq 0 ]; then echo "upsStatus='n/a'" else + echo "upsStatus='${status}'" # get battery level if possible if [ "${status}" = "ONLINE" ] || [ "${status}" = "ONBATT" ]; then - status=$(apcaccess -p BCHARGE | xargs | cut -d "." -f1) - echo "upsStatus='${status}%'" - else - echo "upsStatus='${status}'" + battery=$(apcaccess -p BCHARGE | xargs | cut -d "." -f1) + echo "upsBattery='${battery}%'" fi fi exit 0