From c811cb2ed0e851db52925e58e3ca5b284e57ea9c Mon Sep 17 00:00:00 2001 From: zador-blood-stained Date: Fri, 24 Mar 2017 17:55:46 +0300 Subject: [PATCH] Remove bc dependency for 30-sysinfo MOTD script --- scripts/update-motd.d/30-sysinfo | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/scripts/update-motd.d/30-sysinfo b/scripts/update-motd.d/30-sysinfo index f03e02656..7f5aeca18 100644 --- a/scripts/update-motd.d/30-sysinfo +++ b/scripts/update-motd.d/30-sysinfo @@ -3,14 +3,11 @@ # 30-sysinfo - generate the system information # Copyright (c) 2015 Igor Pecovnik - # define which hard drive you want to monitor storage=/dev/sda1 - # don't edit below here - function displaytime { # we need dedicated function local T=$(cat /proc/uptime | awk '{print $1}' | sed 's/[.].*//') @@ -29,25 +26,19 @@ function displaytime { printf "\x1B[92m%s\x1B[0m\t\t" "$time" } - - - function display() { # $1=name $2=value $3=red_limit $4=minimal_show_limit $5=unit $6=after $7=acs/desc{ # battery red color is opposite, lower number if [[ "$1" == "Battery" ]]; then local great="<"; else local great=">"; fi if [[ -n "$2" && "$2" > "0" && (( "${2%.*}" -ge "$4" )) ]]; then printf "%-14s%s" "$1:" - if (( $(echo "$2 $great $3" | bc -l) )); then echo -ne "\e[0;91m $2"; else echo -ne "\e[0;92m $2"; fi + if awk "BEGIN{exit ! ($2 $great $3)}"; then echo -ne "\e[0;91m $2"; else echo -ne "\e[0;92m $2"; fi printf "%-1s%s\x1B[0m" "$5" printf "%-11s%s\t" "$6" return 1 fi } - - - # Battery info for Allwinner # kernel 4.4+ axp_dir="/sys/power/axp_pmu" @@ -68,8 +59,6 @@ if [[ -e "$axp_dir" ]]; then fi fi - - # legacy kernel axp_dir="/sys/class/power_supply" if [[ -e "$axp_dir" && -e "$axp_dir/battery" ]]; then @@ -147,7 +136,7 @@ if [[ -n $(which temper) && $(dpkg --print-architecture) == armhf ]]; then amb_temp=$(temper -c) if echo $amb_temp | egrep -qv "Couldn't find the USB device"; then amb_temp=$(echo $amb_temp | awk '{print $NF}' | sed 's/C//g') - amb_temp=$(echo "scale=1;${amb_temp}/1" | bc) + amb_temp=$(echo "scale=1;${amb_temp}/1" | grep -oE "\-?[[:digit:]]+.[[:digit:]]") else amb_temp="" fi