Giter Site home page Giter Site logo

creaktive / rainbarf Goto Github PK

View Code? Open in Web Editor NEW
1.2K 48.0 68.0 160 KB

it's like Rainmeter, but for CLI!

Home Page: https://metacpan.org/module/rainbarf

License: Other

Perl 100.00%
tmux powerline cpu memory battery monitoring chart graph widget rainmeter

rainbarf's Introduction

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.

rainbarf's People

Contributors

bitdeli-chef avatar bsdlme avatar creaktive avatar jh3 avatar jmatth avatar sarahhodne avatar sergeyromanov avatar tjormola avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rainbarf's Issues

If last battery is not present, no info is retrieved at all

if /pro/acpy/info has BAT0 and BAT1 and both have info and state and the last has content

present: no

Which would result in an error like

Use of uninitialized value $battery{"charging_state"} in string ne at …/bin/rainbarf line 387.

It overrules earlier batteries found. The loop should probably be changed to

        if (grep {
                -d $_
                and -e ($acpi_info  ||= qq($_/info))
                and -e ($acpi_state ||= qq($_/state))
            } sort glob q(/proc/acpi/battery/BAT[0-9])
        ) {
            for my $file ($acpi_info, $acpi_state) {

I changed = to ||=.

Add a --tick-interval or similar option.

Currently each time rainbarf is executed, it ticks the graph over by one character. In Tmux this happens every 15 seconds by default, giving a nice long historical CPU graph. However I personally have Tmux update the status every second, giving me 38 seconds worth of CPU history.

Hence I'd like to suggest an option that sets how many times rainbarf needs to run before the graph is ticked over once. By default it would obviously be set to 1.

I do realize it would make things a bit more complex. For example if the tick-interval option is set to 15, the each block in the graph should probably be an average CPU usage from the past 15 runs, rather than what it is at the moment rainbarf runs.

How to read the chart

Just wanted to make sure I understand the panel:

  • Bars along the whole horizontal line represent CPU load where X-axis is time and Y-axis is load. Bars have nothing in common with colored areas.
  • 5 colored areas divide horizontal line (like it is in a PIE chart) by representing current RAM status, where GREEN is free memory, RED area is Wired, YELLOW is active, BLUE is inactive and CYAN is buffer cache. So, for instance, if YELLOW area takes 50% of line, that means 50% is active and so on.

Is that all correct or I misunderstood something?

customizing/resizing the actual bar width

Hi, is it possible to customise or set the width for CPU/RAM/SWAP manually?
My tmux shows a huge chart for RAM/SWAP (I have 12Gb Ram and 30Gb swap) and a tiny only chart for the rest:

screenshot from 2015-12-18 19 58 25

How to implement in Python powerline as segment?

Hello,

I'm using https://github.com/powerline/powerline and try to add rainbarf. By default it looks like this in tmux:

bildschirmfoto 2015-02-01 um 17 39 37

When I now add the rainbarf through my `.tmux.conf, it'll look like this:

bildschirmfoto 2015-02-01 um 17 41 58

As you can see, it'll replace the complete right segement group of Powerline, but i actually want to add it as additional segment in there.

Any ideas how to do so?

(Please note, I usually have wider shell windows, so the width in the screenshots above is not the issue of this problem)

Thanks in advance.

ANSI colors tmux in iterm

Ok, so this probably isn't bug , and it is definately due to https://github.com/creaktive/rainbarf#color-scheme , but I don't understand why it happens.

I have tmux running inside iTerm3 with FishTank theme, (but I tried like ~30 themes), and rainbarf only shows CPU graph with --rgb inside tmux. BUT! it works fine when called directly from shell with--bright. I guess it has to be some tmux settings, but I can't figure out which one, any ideas?

Use of uninitialized value $battery

Unless I pass --nobattery on a desktop machine, rainbarf crashes with the following error:

$ ./rainbarf 
Use of uninitialized value $battery{"f"} in string eq at ./rainbarf line 358.
Use of uninitialized value $battery{"f"} in string eq at ./rainbarf line 358.
Use of uninitialized value $battery{"f"} in string eq at ./rainbarf line 358.
Use of uninitialized value $battery{"e"} in pattern match (m//) at ./rainbarf line 363.
Use of uninitialized value in division (/) at ./rainbarf line 364.
Use of uninitialized value in division (/) at ./rainbarf line 364.

Macports build

...is quite outdated. Is it planned to update it someday?

> port info rainbarf
rainbarf @1.1 (sysutils)

Description:          rainbarf: CPU/RAM/battery stats chart bar for tmux (and GNU screen)
Homepage:             https://github.com/creaktive/rainbarf

Build Dependencies:   perl5
Platforms:            darwin
License:              Artistic-1 GPL
Maintainers:          [email protected]

Thanks.

Panel seems blank

All I see in the right corner of tmux panel is this:

rainbarf

What could be wrong?

OS: CentOS 6
Theme: Solarized dark (actually I've tried light with no luck)
Terminal: Windows PuTTy

No values in the output

Works just fine elsewhere.

Debian 9.3
Linux 4.9.0-4-amd64
tmux 2.6  
bash 4.4.12  
latest rainbarf installed from CPAN  

Output of rainbarf --screen:

{gg}▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁{rr}▁{yy}▁▁▁▁▁▁{bb}▁▁▁▁{cc}{= dd}

Output stays the same irrespective of load/cpu/mem usage and battery status.
Tried various combinations of parameters, but without much of success.

Remove perldoc/groff dependency

From Pod::Usage man page:

-noperldoc
By default, Pod::Usage will call perldoc when -verbose >= 2 is specified. This does not work well e.g. if the script was packed with PAR. The -noperldoc option suppresses the external call to perldoc and uses the simple text formatter (Pod::Text) to output the POD.

Options for specifying colors used by graphs

Personally this applies specifically when using the --tmux and --rgb options.

In short, I have custom themes which I use for Tmux, with specifically set color values. It would be nice if rainbarf supported options so I could specify exactly which color value was used for foreground and background for each part of rainbarf's output.

Add an option to specify where CPU states are saved

Please add an option to specify where CPU stats are saved, e.g.:

--datfile filename
  Specify the file to log CPU stats to. (Default $HOME/.rainbarf.dat)

I myself would like it saved in ~/.cache/rainbarf.dat

Rainbarf appears to be adding a newline in Tmux

This has happened recently and can only attribute to some update. It only happens in OSX so far, and what I get is a newline is added every time I press [ENTER] regardless of UI interaction.
See example below.

Screenshot 2019-04-08 at 09 31 56

Failed to install: Can't locate Module/Build.pm

I'm installing via perl Build.pl method and am getting following error:

Can't locate Module/Build.pm in @INC (@INC contains: /usr/local/lib/perl5 /usr/local/share/perl5 /usr/lib/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib/perl5 /usr/share/perl5 .) at Build.PL line 4.
BEGIN failed--compilation aborted at Build.PL line 4.

OS: CentOS 6
Perl: v5.10.1

Please advise

rainbarf fails in macOS sandbox during Homebrew CI

I can avoid this by passing --help, but a regular invocation without options leads to

iMac-TMP:rainbarf joe$ brew test -v rainbarf
Testing rainbarf
==> Using the sandbox
/usr/bin/sandbox-exec -f /tmp/homebrew20160906-26936-h2bs95.sb /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby -W0 -I /usr/local/Library/Homebrew -- /usr/local/Library/Homebrew/test.rb /usr/local/Library/Taps/homebrew/homebrew-core/Formula/rainbarf.rb -v --HEAD
==> /usr/local/Cellar/rainbarf/HEAD-a574fad/bin/rainbarf
Can't exec "/usr/bin/top": Operation not permitted at /usr/local/Cellar/rainbarf/HEAD-a574fad/bin/rainbarf line 243.
Use of uninitialized value $top{"cpu_usage"} in split at /usr/local/Cellar/rainbarf/HEAD-a574fad/bin/rainbarf line 306.
Use of uninitialized value $usage{"idle"} in division (/) at /usr/local/Cellar/rainbarf/HEAD-a574fad/bin/rainbarf line 308.
Use of uninitialized value $top{"physmem"} in pattern match (m//) at /usr/local/Cellar/rainbarf/HEAD-a574fad/bin/rainbarf line 315.
Use of uninitialized value $top{"physmem"} in split at /usr/local/Cellar/rainbarf/HEAD-a574fad/bin/rainbarf line 318.
Use of uninitialized value in division (/) at /usr/local/Cellar/rainbarf/HEAD-a574fad/bin/rainbarf line 99.
Illegal division by zero at /usr/local/Cellar/rainbarf/HEAD-a574fad/bin/rainbarf line 99.
==> Sandbox log
Sep  6 02:44:20 sandboxd[140]: perl5.18(26945) deny forbidden-exec-sugid
Error: rainbarf: failed
Failed executing: /usr/local/Cellar/rainbarf/HEAD-a574fad/bin/rainbarf 
/usr/local/Library/Homebrew/formula.rb:1597:in `block in system'
/usr/local/Library/Homebrew/formula.rb:1534:in `open'
/usr/local/Library/Homebrew/formula.rb:1534:in `system'
/usr/local/Library/Taps/homebrew/homebrew-core/Formula/rainbarf.rb:22:in `block in <class:Rainbarf>'
/usr/local/Library/Homebrew/formula.rb:1435:in `block (2 levels) in run_test'
/usr/local/Library/Homebrew/formula.rb:764:in `with_logging'
/usr/local/Library/Homebrew/formula.rb:1434:in `block in run_test'
/usr/local/Library/Homebrew/extend/fileutils.rb:14:in `block in mktemp'
/usr/local/Library/Homebrew/extend/fileutils.rb:74:in `block in run'
/usr/local/Library/Homebrew/extend/fileutils.rb:74:in `chdir'
/usr/local/Library/Homebrew/extend/fileutils.rb:74:in `run'
/usr/local/Library/Homebrew/extend/fileutils.rb:13:in `mktemp'
/usr/local/Library/Homebrew/formula.rb:1428:in `run_test'
/usr/local/Library/Homebrew/test.rb:28:in `block in <main>'
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/timeout.rb:66:in `timeout'
/usr/local/Library/Homebrew/test.rb:27:in `<main>'

perl Build.PL complains about missing files

When trying to follow the instruction, I got the following gripe:

$ perl Build.PL
WARNING: the following files are missing in your kit:
META.json
META.yml
README
Please inform the author.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.