for line in"${dfs[@]}"; do # get disk usage usage=$(echo"$line" | awk '{print $2}' | sed 's/%//') used_width=$((($usage*$bar_width)/100)) # color is green if usage < max_usage, else red if [ "${usage}" -ge "${max_usage}" ]; then color=$red else color=$green fi # print green/red bar until used_width bar="[${color}" for ((i=0; i<$used_width; i++)); do bar+="=" done # print dimmmed bar until end bar+="${white}${dim}" for ((i=$used_width; i<$bar_width; i++)); do bar+="=" done bar+="${undim}]" # print usage line & bar echo"${line}" | awk '{ printf("%-31s%+3s used out of %+4s\n", $1, $2, $3); }' | sed -e 's/^/ /' echo -e "${bar}" | sed -e 's/^/ /' done
service_status=() # get status of all services for service in"${services[@]}"; do service_status+=($(systemctl is-active "$service")) done
out="" for i in${!services[@]}; do # color green if service is active, else red if [[ "${service_status[$i]}" == "active" ]]; then out+="${services[$i]}:,${green}${service_status[$i]}${undim}," else out+="${services[$i]}:,${red}${service_status[$i]}${undim}," fi # insert \n every $COLUMNS column if [ $((($i+1) % $COLUMNS)) -eq 0 ]; then out+="\n" fi done out+="\n"