refactor the mess into subs

master
neingeist 10 years ago
parent ff1d80a7c2
commit a532814e5e

@ -39,6 +39,7 @@ sub magic_level {
return $new_level;
}
sub conky_fs {
my $fs = Sys::Filesystem->new();
my @filesystems = $fs->filesystems();
@ -87,9 +88,9 @@ for my $f (@filesystems) {
$mount_point
);
}
}
# hddtemp
sub conky_hddtemp {
my $color_toocold = "#0000ff";
my $color_toohot = "#ff0000";
@ -117,14 +118,15 @@ for (my $i = 0; $i < $diskcount; $i++) {
printf " \${color #98c2c7}%s\$color ", $dev;
printf "\${color $color}%02.f°%s\$color\n", $temp, $unit;
}
}
# mdstat
sub conky_mdstat {
open my $fh, "<", "/proc/mdstat";
my $md_current;
my $md_current_state;
my $md_current_mdstat;
sub print_md_current_state {
my $print_md_current_state = sub {
if (defined $md_current) {
my $color = $color_ok;
my $print_mdstat = 0;
@ -149,14 +151,14 @@ sub print_md_current_state {
$md_current_mdstat;
}
}
}
};
while (my $line = <$fh>) {
next if $line =~ /^Personalities\s*:/xsmi;
next if $line =~ /^unused\sdevices\s*:/xsmi;
if ($line =~ /^(.*) : /) {
print_md_current_state();
&$print_md_current_state();
$md_current = $1;
$md_current_state = undef;
@ -170,6 +172,11 @@ while (my $line = <$fh>) {
$md_current_mdstat .= $line;
}
close $fh;
print_md_current_state();
&$print_md_current_state();
}
conky_fs();
conky_hddtemp();
conky_mdstat();
# vim:textwidth=120:

Loading…
Cancel
Save