From 058a2ef508c090b0cc28f1afa58eeff9fe435851 Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Mon, 24 Feb 2025 13:36:14 +1000 Subject: [PATCH 1/4] Prevent transient error messages where no temperature is provided Signed-off-by: Rob Gill --- padd.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/padd.sh b/padd.sh index 329e597..f98f79b 100755 --- a/padd.sh +++ b/padd.sh @@ -414,8 +414,10 @@ GetSystemInformation() { # CPU temperature and unit cpu_temp_raw=$(GetPADDValue sensors.cpu_temp) - cpu_temp=$(printf "%.1f" "${cpu_temp_raw}") - temp_unit=$(echo "${padd_data}" | GetPADDValue sensors.unit) + if [ $cpu_temp_raw != null ]; then + cpu_temp=$(printf "%.1f" "${cpu_temp_raw}") + temp_unit=$(echo "${padd_data}" | GetPADDValue sensors.unit) + fi # Temp + Unit if [ "${temp_unit}" = "C" ]; then From 9f7c97f75c732eda02cb0b0958e44b64bbe02e76 Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Tue, 25 Feb 2025 08:25:08 +1000 Subject: [PATCH 2/4] Adjust displayed temperature to read "N/A" if not reported. Align printf text padding to account for presence/absence of unicode degree symbol Signed-off-by: Rob Gill --- padd.sh | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/padd.sh b/padd.sh index f98f79b..0499c7e 100755 --- a/padd.sh +++ b/padd.sh @@ -424,19 +424,21 @@ GetSystemInformation() { temperature="${cpu_temp}°${temp_unit}" # no conversion needed cpu_temp_celsius="$(echo "${cpu_temp}" | awk -F '.' '{print $1}')" + temp_unicode=true elif [ "${temp_unit}" = "F" ]; then temperature="${cpu_temp}°${temp_unit}" # convert to Celsius for limit checking cpu_temp_celsius="$(echo "${cpu_temp}" | awk '{print ($1-32) * 5 / 9}' | awk -F '.' '{print $1}')" + temp_unicode=true elif [ "${temp_unit}" = "K" ]; then # no ° for Kelvin temperature="${cpu_temp}${temp_unit}" # convert to Celsius for limit checking cpu_temp_celsius="$(echo "${cpu_temp}" | awk '{print $1 - 273.15}' | awk -F '.' '{print $1}')" else # unknown unit - temperature="${cpu_temp}°?" + temperature="N/A" # no conversion needed - cpu_temp_celsius=0 + cpu_temp_celsius=-274 fi # CPU temperature heatmap @@ -450,8 +452,10 @@ GetSystemInformation() { temp_heatmap=${magenta_text} elif [ "${cpu_temp_celsius}" -gt 60 ]; then temp_heatmap=${blue_text} - else + elif [ "${cpu_temp_celsius}" -gt -274 ]; then temp_heatmap=${cyan_text} + else + temp_heatmap=${clear_text} fi # CPU, load, heatmap @@ -1149,6 +1153,11 @@ PrintDashboard() { elif [ "$1" = "regular" ] || [ "$1" = "slim" ]; then # slim is a screen with at least 60 columns and exactly 21 lines # regular is a screen at least 60x22 (columns x lines) + if [ "$temp_unicode" = true ]; then + temp_padding=21 + else + temp_padding=20 + fi if [ "$1" = "slim" ]; then moveXOffset; printf "%s${clear_line}\n" "${padd_text}${dim_text}slim${reset_text} ${version_info}${reset_text}" moveXOffset; printf "%s${clear_line}\n" " PADD ${padd_version_heatmap}${padd_version}${reset_text} ${full_status}${reset_text}" @@ -1175,10 +1184,15 @@ PrintDashboard() { moveXOffset; printf " %-10s%-16s%-6s${dhcp_range_heatmap}%-36s${reset_text}${clear_line}\n" "DHCP:" "${dhcp_check_box}" "Range" "${dhcp_range}" moveXOffset; printf "%s${clear_line}\n" "${bold_text}SYSTEM =====================================================${reset_text}" moveXOffset; printf " %-10s%-39s${clear_line}\n" "Uptime:" "${system_uptime}" - moveXOffset; printf " %-10s${temp_heatmap}%-21s${reset_text}%-10s${cpu_load_1_heatmap}%-4s${reset_text}, ${cpu_load_5_heatmap}%-4s${reset_text}, ${cpu_load_15_heatmap}%-4s${reset_text}${clear_line}\n" "CPU Temp:" "${temperature}" "CPU Load:" "${cpu_load_1}" "${cpu_load_5}" "${cpu_load_15}" + moveXOffset; printf " %-10s${temp_heatmap}%-""${temp_padding}""s${reset_text}%-10s${cpu_load_1_heatmap}%-4s${reset_text}, ${cpu_load_5_heatmap}%-4s${reset_text}, ${cpu_load_15_heatmap}%-4s${reset_text}${clear_line}\n" "CPU Temp:" "${temperature}" "CPU Load:" "${cpu_load_1}" "${cpu_load_5}" "${cpu_load_15}" moveXOffset; printf " %-10s[${memory_heatmap}%-10s${reset_text}] %-6s %-10s[${cpu_load_1_heatmap}%-10s${reset_text}] %-5s${clear_line}" "Memory:" "${memory_bar}" "${memory_percent}%" "CPU Load:" "${cpu_bar}" "${cpu_percent}%" else # ${padd_size} = mega # mega is a screen with at least 80 columns and 26 lines + if [ "$temp_unicode" = true ]; then + temp_padding=10 + else + temp_padding=9 + fi moveXOffset; printf "%s${clear_line}\n" "${padd_logo_retro_1}" moveXOffset; printf "%s${clear_line}\n" "${padd_logo_retro_2} ${version_info}, PADD ${padd_version_heatmap}${padd_version}${reset_text}" moveXOffset; printf "%s${clear_line}\n" "${padd_logo_retro_3} ${dns_check_box} DNS ${ftl_check_box} FTL ${mega_status}${reset_text}" @@ -1204,7 +1218,7 @@ PrintDashboard() { moveXOffset; printf "%s${clear_line}\n" "${bold_text}SYSTEM =========================================================================${reset_text}" moveXOffset; printf " %-10s%-39s${clear_line}\n" "Device:" "${sys_model}" moveXOffset; printf " %-10s%-39s %-10s[${memory_heatmap}%-10s${reset_text}] %-6s${clear_line}\n" "Uptime:" "${system_uptime}" "Memory:" "${memory_bar}" "${memory_percent}%" - moveXOffset; printf " %-10s${temp_heatmap}%-10s${reset_text} %-10s${cpu_load_1_heatmap}%-4s${reset_text}, ${cpu_load_5_heatmap}%-4s${reset_text}, ${cpu_load_15_heatmap}%-7s${reset_text} %-10s[${memory_heatmap}%-10s${reset_text}] %-6s${clear_line}" "CPU Temp:" "${temperature}" "CPU Load:" "${cpu_load_1}" "${cpu_load_5}" "${cpu_load_15}" "CPU Load:" "${cpu_bar}" "${cpu_percent}%" + moveXOffset; printf " %-10s${temp_heatmap}%-""${temp_padding}""s${reset_text} %-10s${cpu_load_1_heatmap}%-4s${reset_text}, ${cpu_load_5_heatmap}%-4s${reset_text}, ${cpu_load_15_heatmap}%-7s${reset_text} %-10s[${memory_heatmap}%-10s${reset_text}] %-6s${clear_line}" "CPU Temp:" "${temperature}" "CPU Load:" "${cpu_load_1}" "${cpu_load_5}" "${cpu_load_15}" "CPU Load:" "${cpu_bar}" "${cpu_percent}%" fi # Clear to end of screen (below the drawn dashboard) From 6ae23eb37eb9c13a125d36331e1579327e05247a Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Wed, 26 Feb 2025 19:09:47 +1000 Subject: [PATCH 3/4] Move string padding logic Signed-off-by: Rob Gill --- padd.sh | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/padd.sh b/padd.sh index 0499c7e..57ac0aa 100755 --- a/padd.sh +++ b/padd.sh @@ -922,6 +922,11 @@ GenerateSizeDependendOutput() { top_domain=$(truncateString "$top_domain_raw" 48) top_client=$(truncateString "$top_client_raw" 48) + if [ "$temp_unicode" = true ]; then + temp_padding=21 + else + temp_padding=20 + fi elif [ "$1" = "mega" ]; then ads_blocked_bar=$(BarGenerator "$ads_percentage_today" 30 "color") @@ -931,6 +936,12 @@ GenerateSizeDependendOutput() { top_domain=$(truncateString "$top_domain_raw" 68) top_client=$(truncateString "$top_client_raw" 68) + if [ "$temp_unicode" = true ]; then + temp_padding=10 + else + temp_padding=9 + fi + fi # System uptime @@ -1153,11 +1164,6 @@ PrintDashboard() { elif [ "$1" = "regular" ] || [ "$1" = "slim" ]; then # slim is a screen with at least 60 columns and exactly 21 lines # regular is a screen at least 60x22 (columns x lines) - if [ "$temp_unicode" = true ]; then - temp_padding=21 - else - temp_padding=20 - fi if [ "$1" = "slim" ]; then moveXOffset; printf "%s${clear_line}\n" "${padd_text}${dim_text}slim${reset_text} ${version_info}${reset_text}" moveXOffset; printf "%s${clear_line}\n" " PADD ${padd_version_heatmap}${padd_version}${reset_text} ${full_status}${reset_text}" @@ -1188,11 +1194,6 @@ PrintDashboard() { moveXOffset; printf " %-10s[${memory_heatmap}%-10s${reset_text}] %-6s %-10s[${cpu_load_1_heatmap}%-10s${reset_text}] %-5s${clear_line}" "Memory:" "${memory_bar}" "${memory_percent}%" "CPU Load:" "${cpu_bar}" "${cpu_percent}%" else # ${padd_size} = mega # mega is a screen with at least 80 columns and 26 lines - if [ "$temp_unicode" = true ]; then - temp_padding=10 - else - temp_padding=9 - fi moveXOffset; printf "%s${clear_line}\n" "${padd_logo_retro_1}" moveXOffset; printf "%s${clear_line}\n" "${padd_logo_retro_2} ${version_info}, PADD ${padd_version_heatmap}${padd_version}${reset_text}" moveXOffset; printf "%s${clear_line}\n" "${padd_logo_retro_3} ${dns_check_box} DNS ${ftl_check_box} FTL ${mega_status}${reset_text}" From 2b4980babfa9df514e13360cb8abc24a768f856c Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Thu, 27 Feb 2025 05:03:11 +1000 Subject: [PATCH 4/4] Explicitly clear unicode padding flag on non-unicode units Signed-off-by: Rob Gill --- padd.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/padd.sh b/padd.sh index 57ac0aa..8365dc1 100755 --- a/padd.sh +++ b/padd.sh @@ -435,10 +435,12 @@ GetSystemInformation() { temperature="${cpu_temp}${temp_unit}" # convert to Celsius for limit checking cpu_temp_celsius="$(echo "${cpu_temp}" | awk '{print $1 - 273.15}' | awk -F '.' '{print $1}')" + temp_unicode=false else # unknown unit temperature="N/A" # no conversion needed cpu_temp_celsius=-274 + temp_unicode=false fi # CPU temperature heatmap