🐛 handle invalid numbers
This commit is contained in:
parent
15c3d5062e
commit
e4b7302210
1 changed files with 7 additions and 2 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue