From 04e3e300bd0c6c01ba5e8a3a3f0d40ea29c95945 Mon Sep 17 00:00:00 2001 From: 0scar Date: Tue, 14 Mar 2023 15:10:25 +0100 Subject: Update cpuinfo script * Remove colors * Dont print anything if load < 1 * Conform to posix sh --- .local/bin/statusbar/cpuinfo | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to '.local/bin/statusbar') diff --git a/.local/bin/statusbar/cpuinfo b/.local/bin/statusbar/cpuinfo index 05ab3de..78920a5 100755 --- a/.local/bin/statusbar/cpuinfo +++ b/.local/bin/statusbar/cpuinfo @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh set -e ARG=${1:-$BLOCK_BUTTON} @@ -20,16 +20,12 @@ case $ARG in ;; esac -# Thermals -# "Never cat something into awk", yeah, but it won't function properly if it -# encounters a missing `/temp`-file. -TEMP="$(cat /sys/class/thermal/thermal_zone*/temp 2>/dev/null)" -TEMP="$(echo "${TEMP}" | awk '{s+=$1}END{printf "%.1f", s / (1000*NR)}' )" -# Color red if temp > 45 -TEMP=`(( $(echo "$TEMP > 45" | bc -l) )) && echo -en "\x0c${TEMP}\x0b" || echo -en "$TEMP"` +LOAD_1m=$(sed -E 's/^([^ ]+).*/\1/' /proc/loadavg | tr -d '\n') -# Load -LOAD=$(sed -Ee 's/^([0-9]+\.[0-9]+) .*/\1/g' /proc/loadavg | tr -d '\n') +# Silence is golden +[ "$(echo "${LOAD_1m} < 1" | bc -l)" -eq 1 ] && exit 0 +# Thermals +TEMP="$(awk '{s+=$1}END{printf "%.1f", s / (1000*NR)}' /sys/class/thermal/thermal_zone*/temp)" -echo -en "[${LOAD} \x0f\x0b ${TEMP}°]" +printf "[%s  %s°]" "${LOAD_1m}" "${TEMP}" -- cgit v1.3