Skip to content

A Legend of Zelda inspired health-bar battery meter for the CLI and GUI

License

Notifications You must be signed in to change notification settings

amagura/zelda-battery

Repository files navigation

ZBatt Build Status Circle CI

A Legend of Zelda inspired health-bar battery meter for Shell prompts and Taskbars

Supported Platforms

Linux

Kernels >= 2.6.24 are supported; support for older kernels is not a priority.

UNIX

BSD is well supported; as long as you have sysctlbyname you should be fine.

Solaris support is still fairly new and experimental, but as long as you have sys/pm.h you should be good.

UNIX systems supported:

  • DragonFlyBSD
  • FreeBSD
  • OpenIndiana (Solaris)

UNIX systems probably supported:

  • NetBSD
  • Midnight BSD
  • OpenSolaris
  • (Anything based on FreeBSD)

UNIX systems unsupported:

  • OpenBSD
  • SmartOS (Solaris)

Windows

Windows XP and later.

Runtime Dependencies

Linux and UNIX

  • Python (GUI)
  • GTK+3 (GUI)
  • PyGObject (GUI)

† Python v2.x.xx is no longer supported
‡ Support for GTk+2 might be added back in future releases

Windows

Windows provides everything you'll need.

Make Dependencies

  • GNU Autotools (i.e. automake, autoconf)
  • Make

Linux and UNIX

  • C99 compliant C compiler
  • Cython (GUI)
  • pkgconf (GUI)

Windows

  • C++11 compliant C++ compiler

Building

  1. autoreconf -fi
  2. ./configure
  3. make

Installing

  1. make DESTDIR="<DIR>" install

If the install fails because of permissions, try running it with sudo.


Alternatively, you can also just place the binaries zbatc, zbatt, and (if you built the GUI) gzbatt where ever you like.

Examples

The command-line is extremely flexible, so while there are defaults there's nothing stopping you from defining your own experience.

Git-esque

example of the git style

./zbatc -c 32; ./zbatt -r -f +; ./zbatc -c 31; ./zbatt -x -e -

To make it even easier to integrate ZBatt with your current command-line experience, I've gone ahead and provided examples for some shells.

Zsh

example showing zelda-battery in a Zsh prompt

PROMPT="%{$(./zbatc)%}$(./zbatt)%{�[0;0m%} %m%# "

## run TRAPALRM every $TMOUT seconds
TMOUT=60 # refresh the terminal prompt every 60 seconds

TRAPALRM ()
{
    zle reset-prompt # refreshs the terminal prompt
}

Bash

example showing zelda-battery in a Bash prompt

PS1='\[$(./zbatc)\]$(./zbatt)\[\033[0;0m\] [\h \W]\$ '

Mksh (Korn Shell)

example showing zelda-battery in a Mksh prompt

PS1=$'$(./zbatc)'$(./zbatt)$'\033[0;0m'\ ["$(hostname)"]\

Tcsh

example showing zbatt in a tcsh prompt

set prompt="%{`./zbatc`%}`./zbatt` %{\033[0;0m%}%m "

Notes

Zsh

As long as you use the TMOUT and TRAPALRM/zle reset-prompt stuff, your Zsh prompt should refresh itself every 60 seconds.

Bash

AFAIK there is no way to periodically refresh a bash prompt without either running clear/Ctrl-L or pressing enter, which causes the prompt to be redrawn.

Submissions

Screenshot, command-line prompt examples, and all other submissions are appreciated as always. Thank you.