App-rainbarf

 view release on metacpan or  search on metacpan

rainbarf  view on Meta::CPAN

Or, under I<GNOME Terminal>:

 set-option -g status-utf8 on
 set -g status-right '#(rainbarf --rgb)'

Reload the tmux config by running C<tmux source-file ~/.tmux.conf>.

=head1 CONFIGURATION FILE

C<~/.rainbarf.conf> can be used to persistently store L</OPTIONS>:

 # example configuration file
 width=20   # widget width
 bolt       # fancy charging character
 remaining  # display remaining battery
 rgb        # 256-colored palette

L</OPTIONS> specified via command line override that values.
Configuration file can be specified via C<RAINBARF> environment variable:

 RAINBARF=~/.rainbarf.conf rainbarf

=head1 OPTIONS

=over 4

=item C<--help>

This.

=item C<--[no]battery>

Display the battery charge indicator.
Enabled by default.

=item C<--[no]remaining>

Display the time remaining until the battery is fully charged/empty. See L</CAVEAT>.
Disabled by default.

=item C<--[no]bolt>

Display even fancier battery indicator.
Disabled by default.

=item C<--[no]bright>

Tricky one. Disabled by default. See L</CAVEAT>.

=item C<--[no]rgb>

Use the B<RGB> palette instead of the system colors.
Also disabled by default, for the same reasons as above.

=item C<--fg COLOR_NAME>

Force chart foreground color.

=item C<--bg COLOR_NAME>

Force chart background color.

=item C<--[no]loadavg>

Use L<load average|https://en.wikipedia.org/wiki/Load_(computing)> metric instead of CPU utilization.
You might want to set the C<--max> threshold since this is an absolute value and has varying ranges on different systems.
Disabled by default.

=item C<--[no]swap>

Display the swap usage.
Used swap amount is added to the total amount, but the free swap amount is not!
Disabled by default.

=item C<--max NUMBER>

Maximum C<loadavg> you expect before rescaling the chart. Default is 1.

=item C<--order INDEXES>

Specify the memory usage bar order.
The default is C<fwaic> ( B<f>ree, B<w>ired, B<a>ctive, B<i>nactive & B<c>ached ).

=item C<--[no]tmux>

Force C<tmux> colors mode.
By default, L<rainbarf> detects automatically if it is being called from C<tmux> or from the interactive shell.

=item C<--screen>

L<screen(1)|http://manpages.ubuntu.com/manpages/hardy/man1/screen.1.html> colors mode. B<Experimental>. See L</CAVEAT>.

=item C<--width NUMBER>

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>

=item C<--skip NUMBER>

Do not write CPU stats if file already exists and is newer than this many seconds.
Useful if you refresh C<tmux> status quite frequently.

=back

=head1 CAVEAT

=head2 Time remaining

If the C<--remaining> option is present but you do not see the time in your status bar, you may need to increase the value of C<status-right-length> to 48.

=head2 Color scheme

If you only see the memory usage bars but no CPU utilization chart, that's because your terminal's color scheme need an explicit distinction between foreground and background colors.
For instance, "red on red background" will be displayed as a red block on such terminals.
Thus, you may need the ANSI B<bright> attribute for greater contrast, or maybe consider switching to the 256-color palette.
There are some issues with that, though:

=over 4

=item 1.

Other color schemes (notably, L<solarized|http://ethanschoonover.com/solarized>) have different meaning for the ANSI B<bright> attribute.
So using it will result in a quite psychedelic appearance.
256-color pallette, activated by the C<--rgb> flag, is unaffected by that.

=item 2.

The older versions of L<Term::ANSIColor> dependency do not recognize bright/RGB settings, falling back to the default behavior (plain 16 colors).
However, the whole L<Term::ANSIColor> is optional, it is only required to preview the effects of the L</OPTIONS> via command line before actually editing the F<~/.tmux.conf>.
That is, C<rainbarf --bright --tmux> B<is guaranteed to work> despite the outdated L<Term::ANSIColor>!

=back

Another option is skipping the system colors altogether and use the B<RGB> palette (C<rainbarf --rgb>).
This fixes the I<issue 1>, but doesn't affect the I<issue 2>.
It still looks better, though.

=head2 Persistent storage

CPU utilization stats are persistently stored in the F<~/.rainbarf.dat> file.
Every L<rainbarf> execution will update and rotate that file.
Since C<tmux> calls L<rainbarf> periodically (every 15 seconds, by default), the chart will display CPU utilization for the last ~9.5 minutes (15 * 38).
Thus, several C<tmux> instances running simultaneously for the same user will result in a faster chart scrolling.

=head2 screen

Stable C<screen> version unfortunately has a broken UTF-8 handling specifically for the status bar.
Thus, I have only tested the L<rainbarf> with the variant from L<git://git.savannah.gnu.org/screen.git>.
My F<~/.screenrc> contents:

 backtick 1 15 15 rainbarf --bright --screen
 hardstatus string "%1`"
 hardstatus lastline

=head1 REFERENCES

=over 4

=item *

L<top(1)|http://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/top.1.html> is used to get the CPU/RAM stats if no F</proc> filesystem is available.

=item *

L<ioreg(8)|http://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man8/ioreg.8.html> is used to get the battery status on I<Mac OS X>.

=item *

L<ACPI|http://www.tldp.org/howto/acpi-howto/usingacpi.html> is used to get the battery status on I<Linux>.

=item *

L<Battery|https://github.com/Goles/Battery> was a source of inspiration.



( run in 0.678 second using v1.01-cache-2.11-cpan-f56aa216473 )