From e4b7302210b1adc6e44abca2fa353cb79105d8ed Mon Sep 17 00:00:00 2001 From: neingeist Date: Fri, 23 May 2025 21:07:39 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20handle=20invalid=20numbers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- conky-disks | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/conky-disks b/conky-disks index 63c5ab4..93c3b52 100755 --- a/conky-disks +++ b/conky-disks @@ -4,6 +4,7 @@ use utf8; use strict; use warnings; use Carp; +use Scalar::Util qw(looks_like_number); use Sys::Filesystem (); use Filesys::Df qw(df); @@ -112,14 +113,18 @@ sub conky_hddtemp { my $unit = $hddtemp_output[$i*5+4]; my $color = $color_ok; - if ($temp > 40) { + if (not(looks_like_number($temp)) or $temp > 40) { $color = $color_toohot; } elsif ($temp < 25) { $color = $color_toocold; } printf " \${color #98c2c7}%s\$color ", $dev; - printf "\${color $color}%02.f°%s\$color\n", $temp, $unit; + if (looks_like_number($temp)) { + printf "\${color $color}%02.f°%s\$color\n", $temp, $unit; + } else { + printf "\${color $color}%s°%s\$color\n", $temp, $unit; + } } }