diff options
| author | Paul Buetow <paul@buetow.org> | 2011-08-07 13:53:01 +0000 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2011-08-07 13:53:01 +0000 |
| commit | c1f3d3a10971b623e450ecd838cfa59dff6fa192 (patch) | |
| tree | 40e6f3290c700aa262013d1c72e29243ff962a87 | |
| parent | 07a60d3d15fa93283271671e40ba038784de4b13 (diff) | |
Fixed a small bug (last bar was too narrow)
| -rwxr-xr-x | loadbars.pl | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/loadbars.pl b/loadbars.pl index 863ae8f..5f5f5ff 100755 --- a/loadbars.pl +++ b/loadbars.pl @@ -352,11 +352,12 @@ sub main_loop ($@) { } # Avoid division by null - my $width = $CONF{width} / ($num_stats ? $num_stats : 1); + # Also substract 1 (each bar is followed by an 1px separator bar) + my $width = $CONF{width} / ($num_stats ? $num_stats : 1) - 1; - my $barnum = -1; + my $current_barnum = -1; for my $key (sort keys %CPUSTATS) { - ++$barnum; + ++$current_barnum; my ($host, $name) = split ';', $key; next unless defined $CPUSTATS{$key}; @@ -445,7 +446,7 @@ sub main_loop ($@) { $app->print($x, $y, sprintf '%s:', $1); } else { - $app->print($x, $y, sprintf '%i:', $barnum); + $app->print($x, $y, sprintf '%i:', $current_barnum); } $app->print($x, $y+=$space, sprintf '%d%s', $cpuaverage{nice}, 'ni'); |
