Remove bc dependency for 30-sysinfo MOTD script

This commit is contained in:
zador-blood-stained 2017-03-24 17:55:46 +03:00
parent 96e7b00999
commit c811cb2ed0

View file

@ -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