Skip to content

Commit

Permalink
Added the --datfile option, as suggested in issue creaktive#19
Browse files Browse the repository at this point in the history
  • Loading branch information
creaktive committed Oct 29, 2013
1 parent 59acdd4 commit bfdf245
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
3 changes: 3 additions & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ OPTIONS
disabling the battery indicator or raising the "status-right-length"
value in ~/.tmux.conf.

"--datfile FILENAME"
Specify the file to log CPU stats to. Default: $HOME/.rainbarf.dat

CAVEAT
Time remaining
If the "--remaining" option is present but you do not see the time in
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,11 @@ Configuration file can be specified via `RAINBARF` environment variable:
Chart width. Default is 38, so both the chart and the battery indicator fit the `tmux` status line.
Higher values may require disabling the battery indicator or raising the `status-right-length` value in `~/.tmux.conf`.

- `--datfile FILENAME`

Specify the file to log CPU stats to.
Default: `$HOME/.rainbarf.dat`

# CAVEAT

## Time remaining
Expand Down
15 changes: 11 additions & 4 deletions rainbarf
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ my $screen = 0;
my $tmux = not -t \*STDOUT;
my $rgb = 0;

my ($help, $show_battery, $remaining, $bolt, $chart_bg,
$chart_fg, $bright, $loadavg, $swap, $threshold, $width);
my ($help, $show_battery, $remaining, $bolt, $chart_bg, $chart_fg,
$bright, $loadavg, $swap, $threshold, $width, $history);

# parse the options file
my $rcname = exists($ENV{RAINBARF})
Expand Down Expand Up @@ -65,13 +65,12 @@ if (@ARGV) {
q(tmux!) => \$tmux,
q(rgb!) => \$rgb,
q(width=i) => \$width,
q(datfile=s) => \$history,
) or help(-verbose => 1);
}

defaults();

my $history = qq($ENV{HOME}/.rainbarf.dat);

my $chart = eval { lock_retrieve $history };
$chart = [ (0) x $width ] unless defined $chart;

Expand Down Expand Up @@ -146,6 +145,9 @@ sub defaults {
$bolt = (defined $bolt and $bolt) ? chr 0x26a1 : q(|);
require Term::ANSIColor if not $tmux and not $screen;

$history = qq($ENV{HOME}/.rainbarf.dat)
unless defined $history;

return;
}

Expand Down Expand Up @@ -634,6 +636,11 @@ L<screen(1)|http://manpages.ubuntu.com/manpages/hardy/man1/screen.1.html> colors
Chart width. Default is 38, so both the chart and the battery indicator fit the C<tmux> status line.
Higher values may require disabling the battery indicator or raising the C<status-right-length> value in F<~/.tmux.conf>.
=item C<--datfile FILENAME>
Specify the file to log CPU stats to.
Default: F<$HOME/.rainbarf.dat>
=back
=head1 CAVEAT
Expand Down
5 changes: 3 additions & 2 deletions t/01-tmux.t
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ plan skip_all => qq(The platform $^O is unsupported)
my $tmp = File::Temp->newdir;

local $ENV{RAINBARF} = q(/dev/null);
local $ENV{HOME} = $tmp->dirname;
my $file = $tmp->dirname . '/rainbarf.dat';

my $n = 10;

Expand Down Expand Up @@ -41,7 +41,8 @@ for my $i (1 .. $n) {
--nobattery
--swap
--tmux
]),
--datfile
], $file),
qq(pipe $i),
);
chomp(my $line = <$out>);
Expand Down

0 comments on commit bfdf245

Please sign in to comment.