summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2011-08-07 13:53:01 +0000
committerPaul Buetow <paul@buetow.org>2011-08-07 13:53:01 +0000
commitc1f3d3a10971b623e450ecd838cfa59dff6fa192 (patch)
tree40e6f3290c700aa262013d1c72e29243ff962a87
parent07a60d3d15fa93283271671e40ba038784de4b13 (diff)
Fixed a small bug (last bar was too narrow)
-rwxr-xr-xloadbars.pl9
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');