refactor the mess into subs

master
neingeist 10 years ago
parent ff1d80a7c2
commit a532814e5e

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

Loading…
Cancel
Save