• Stars
    star
    1,145
  • Rank 39,346 (Top 0.8 %)
  • Language
    Perl
  • License
    Other
  • Created over 11 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

it's like Rainmeter, but for CLI!

Build Status

NAME

rainbarf - CPU/RAM/battery stats chart bar for tmux (and GNU screen)

VERSION

version 1.4

SYNOPSIS

rainbarf --tmux --width 40 --no-battery

DESCRIPTION

Fancy resource usage charts to put into the tmux status line. The CPU utilization history chart is tinted with the following colors to reflect the system memory allocation:

  • green: free memory;
  • yellow: active memory;
  • blue: inactive memory;
  • red: wired memory on Mac OS X / FreeBSD; "unaccounted" memory on Linux;
  • cyan: cached memory on Linux, buf on FreeBSD.
  • magenta: used swap memory.

If available, battery charge is displayed on the right.

SCREENSHOTS

iTerm2 with tmux-powerline, Solarized theme and Terminus font

rainbarf --battery --remaining --rgb

Mac OS X screenshot

OSX Terminal with Tomorrow Night theme and Menlo font

rainbarf --battery --remaining --no-bright

Mac OS X screenshot, v2

Ubuntu Terminal with default theme and Monospace font

rainbarf --battery --bolt --bright

Ubuntu screenshot

BONUS: an animated zsh prompt!

Proof of concept, use at your own risk!

animated zsh prompt

USAGE

Installation

  • Traditional way:

      perl Build.PL
      ./Build test
      ./Build install
    
  • Homebrew way:

      brew install rainbarf
    
  • MacPorts way:

      port install rainbarf
    
  • CPAN way:

      cpan -i App::rainbarf
    
  • Modern Perl way:

      cpanm git://github.com/creaktive/rainbarf.git
    

Configuration

Add the following line to your ~/.tmux.conf file:

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

Or, under GNOME Terminal:

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

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

CONFIGURATION FILE

~/.rainbarf.conf can be used to persistently store "OPTIONS":

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

"OPTIONS" specified via command line override that values. Configuration file can be specified via RAINBARF environment variable:

RAINBARF=~/.rainbarf.conf rainbarf

OPTIONS

  • --help

    This.

  • --[no]battery

    Display the battery charge indicator. Enabled by default.

  • --[no]remaining

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

  • --[no]bolt

    Display even fancier battery indicator ⚑. Disabled by default.

  • --[no]bright

    Tricky one. Disabled by default. See "CAVEAT".

  • --[no]rgb

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

  • --fg COLOR_NAME

    Force chart foreground color.

  • --bg COLOR_NAME

    Force chart background color.

  • --[no]loadavg

    Use load average metric instead of CPU utilization. You might want to set the --max threshold since this is an absolute value and has varying ranges on different systems. Disabled by default.

  • --[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.

  • --max NUMBER

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

  • --order INDEXES

    Specify the memory usage bar order. The default is fwaic (free, wired, active, inactive & cached).

  • --[no]tmux

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

  • --screen

    screen(1) colors mode. Experimental. See "CAVEAT".

  • --width NUMBER

    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

  • --skip NUMBER

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

CAVEAT

Time remaining

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

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 bright attribute for greater contrast, or maybe consider switching to the 256-color palette. There are some issues with that, though:

  1. Other color schemes (notably, solarized) have different meaning for the ANSI bright attribute. So using it will result in a quite psychedelic appearance. 256-color pallette, activated by the --rgb flag, is unaffected by that.
  2. The older versions of Term::ANSIColor dependency do not recognize bright/RGB settings, falling back to the default behavior (plain 16 colors). However, the whole Term::ANSIColor is optional, it is only required to preview the effects of the "OPTIONS" via command line before actually editing the ~/.tmux.conf. That is, rainbarf --bright --tmux is guaranteed to work despite the outdated Term::ANSIColor!

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

Persistent storage

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

screen

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

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

REFERENCES

  • top(1) is used to get the CPU/RAM stats if no /proc filesystem is available.
  • ioreg(8) is used to get the battery status on Mac OS X.
  • ACPI is used to get the battery status on Linux.
  • Battery was a source of inspiration.
  • Spark was another source of inspiration.

AUTHOR

Stanislaw Pusep [email protected]

CONTRIBUTORS

COPYRIGHT AND LICENSE

This software is copyright (c) 2016 by Stanislaw Pusep [email protected].

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

More Repositories

1

tsh

Tiny SHell - An open-source UNIX backdoor (I'm not the author!)
C
496
star
2

pianolizer

An easy-to-use toolkit for music exploration and visualization, an audio spectrum analyzer helping you turn sounds into piano notes
JavaScript
57
star
3

flare

nRF905 single-chip radio transceiver demodulator + FLARM protocol decoder
C
53
star
4

iStat-Pro.wdgt

Monitor widget: CPU, memory, network, bandwidth and drive. (I'm not the author, just patched the discontinued Dashboard.app widget for my own needs)
JavaScript
29
star
5

dePAC

seamless Proxy Auto-Config (a.k.a. Web Proxy Auto Discovery) for CLI apps
Perl
26
star
6

KeyLab_Essential_Hacks

Disgusting hack put together during a rainy weekend to enable Instant Mapping for Arturia KeyLab Essential MIDI controller in Ableton Live 10.
Python
19
star
7

inPEct

inPEct means "infect", applicable to PE ("Portable Executable") format. It is an executable binder, thus, it's able to join two .exe files in one.
Assembly
17
star
8

LWP-Protocol-Net-Curl

let's make LWP great again!
Perl
14
star
9

Text-SpeedyFx

Extremely Fast Text Feature Extraction for Classification and Indexing
C++
9
star
10

nordvpn-proxy

run NordVPN in a container and expose as a SOCKS/HTTP proxy
Shell
7
star
11

HTML-Untemplate

web scraping assistant
Perl
6
star
12

speedyfx

C implementation of SpeedyFx algorithm
C
6
star
13

Text-Fingerprint

Perl
5
star
14

Algorithm-Burg

extrapolate time series using Burg's method
Perl
5
star
15

ACFTools

ACFTools is a utility for manipulating X-Plane flight simulator aircraft and weapon models without using its Plane Maker. It can decode both Apple and Intel ACF/WPN formats into plain text files with a syntax similar to C, which can be edited and then re-converted into binary data. It is able to extract almost complete 3D models of aircraft (fuselage, floats, tanks, wings, stabs, propellers, engines) and write it in AC3D modeler format. Edited 3D parts can then be merged into plain text and consequently converted into binary ACF files.
Perl
5
star
16

waifu2x-converter-cpp

Dockerfile for DeadSix27's fork of waifu2x-converter-cpp
Dockerfile
4
star
17

myTunes

Access iTunes media files stored on your iDevice through the 'Media/myTunes' folder accessible via SCP, iPhoneBrowser or iFile internal server.
C
4
star
18

CPAN-U

CPAN::U is a collaborative filter based recommendation system for Perl developers
JavaScript
3
star
19

py-speedyfx

Python implementation of the SpeedyFx algorithm
Python
3
star
20

stas-dotfiles

There's no place like $HOME
Perl
3
star
21

AnyEvent-Net-Curl-Queued

Any::Moose wrapper for queued downloads via Net::Curl & AnyEvent
Perl
3
star
22

CrawlerBadPractices

Como fazer um crawler ineficiente
Perl
3
star
23

grp.wcx

Extract/create support for GRP (Duke Nukem 3D and other Build engine-based games group file) file format. First (and only) plugin written in Assembler!
Assembly
3
star
24

LED-toys

Python
3
star
25

Test-Mojibake

Test::Mojibake - check your source for encoding misbehavior
Perl
2
star
26

encephalocoitus

Yet Another BrainFuck Compiler in Perl
Perl
2
star
27

stas-vim

my vim config
Vim Script
2
star
28

PHProxy

Quick&Dirty way to emulate mod_proxy's ProxyPass via mod_rewrite+PHP . Edit the definitions at the start of the code to configure.
PHP
2
star
29

Geo-CEP

Resolve Brazilian city data for a given CEP
Perl
2
star
30

tiny-HTTP-proxy

This is a tiny and highly experimental HTTP/1.0 proxy software that I have written to debug HTTP protocol & it's clients. It is very small and simple, yet useful to reverse-engineering purposes.
C
2
star
31

TicketFeed

Scraper que gera feed Atom para extratos de ticket.com.br
Perl
1
star
32

MCGA-Linedraw

Register-only routine for drawing lines on 16-bit x86
Assembly
1
star
33

daemoniac

plays "Iron Maiden - Fear Of The Dark" through PC build-in speaker under DOS/Windows/Linux/FreeBSD
C
1
star
34

github-stats

Perl
1
star
35

LockIt

Multi-purpose BIOS Password Locker
Assembly
1
star
36

AI-MongoDBayes

MapReduce NaΓ―ve Bayes classifier
Perl
1
star
37

parport-LED

controls LED diodes wired directly to a parallel port, under MS-DOS
Assembly
1
star
38

Text-Roman

Allows conversion between Roman and Arabic algarisms.
Perl
1
star
39

HTML-AsText-Fix

extends HTML::Element::as_text() to render text properly
Perl
1
star
40

Data-Printer-Filter-URI

pretty-printing URI objects
Perl
1
star
41

knuckle-cracker

knuckle cracker includes a tool that compares two binary files and generates human-readable (and writable) patch scripts signed with MD5. It features smart string/binary recognition. Non-printable string portions are presented in C-like escaping style ("\x20\7\r\n"). It also features a utility that applies such a patch.
C
1
star
42

GibCounter

QuakeWorld server ranking & stats
Perl
1
star