Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: amagura/zelda-battery
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 3.0
Choose a base ref
...
head repository: amagura/zelda-battery
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Loading
Showing with 4,168 additions and 866 deletions.
  1. +21 −4 .gitignore
  2. +12 −9 .travis.yml
  3. +2 −2 AUTHORS
  4. +11 −14 INSTALL
  5. +89 −10 Makefile.am
  6. +75 −22 README.md
  7. +30 −0 TODO
  8. +17 −0 circle.yml
  9. +275 −107 configure.ac
  10. +12 −0 example.conf
  11. BIN example/FreeBSD-small.png
  12. +1 −0 example/LICENSE
  13. BIN example/awesome-wm.png
  14. BIN example/xp-cli.png
  15. +1 −0 img/.gitignore
  16. +424 −26 img/LICENSE
  17. +30 −12 img/Makefile.am
  18. BIN img/ball-emp10.png
  19. BIN img/ball-emp16.png
  20. BIN img/ball-full10.png
  21. BIN img/ball-full16.png
  22. BIN img/ball-half10.png
  23. BIN img/ball-qemp10.png
  24. BIN img/ball-qfull10.png
  25. +1 −0 img/ball/LICENSE
  26. BIN img/ball/bork.png
  27. BIN img/ball/empty.png
  28. BIN img/ball/full.png
  29. BIN img/ball/half.png
  30. BIN img/ball/nobat.png
  31. BIN img/ball/qempty.png
  32. BIN img/ball/qfull.png
  33. +1 −0 img/orig/LICENSE
  34. BIN img/{ → orig}/bork.png
  35. BIN img/{ → orig}/empty.png
  36. BIN img/{ → orig}/full.png
  37. BIN img/{ → orig}/half.png
  38. BIN img/{ → orig}/nobat.png
  39. BIN img/{ → orig}/qempty.png
  40. BIN img/{ → orig}/qfull.png
  41. +1 −0 man/zbatc.1
  42. +15 −0 man/zbatt.1
  43. +1 −0 mswin
  44. +203 −0 old/configure.ac
  45. +94 −30 src/Makefile.am
  46. +61 −23 src/acpi.c
  47. +1 −1 src/acpi.h
  48. +32 −25 src/{main-color.c → color.c}
  49. +89 −120 src/compat.h
  50. +257 −0 src/concat.c
  51. +42 −0 src/cpeek.c
  52. 0 src/macos/Makefile.am
  53. 0 src/macos/color.m
  54. 0 src/macos/main.m
  55. 0 src/macos/text.m
  56. +0 −197 src/main-gui.c
  57. +0 −52 src/main-gui.h
  58. +5 −105 src/main.c
  59. +74 −21 src/main.h
  60. +97 −64 src/main_gui.pyx
  61. +128 −0 src/mswin/Makefile.am
  62. +46 −0 src/mswin/color.cxx
  63. +23 −0 src/mswin/main.cxx
  64. +98 −0 src/mswin/main.hxx
  65. +68 −0 src/mswin/text.cxx
  66. +55 −8 src/power.c
  67. +3 −2 src/power.h
  68. +0 −8 src/test.scm
  69. +1,695 −0 src/test/configure
  70. +22 −0 src/test/configure.ac
  71. +24 −4 src/{main-text.c → text.c}
  72. +16 −0 win32.sh
  73. +16 −0 win64.sh
25 changes: 21 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -6,23 +6,40 @@ zba
zbl
zb-color
zb-text
!/archive/**/zbatc
!/archive/**/zbatt
!/archive/**/gzbatt
zbatt
zbatc
gzbatt
zbatt.exe
zbatc.exe
gzbatt.exe
main_gui.c
main_gui.co

# emacs files
.\#*

# automake stuff
autom4te.cache
config.log
config.status
config.h*
aclocal.m4
Makefile
#Makefile.in
Makefile.in
.deps
configure
build-aux
stamp-h1

# misc
/tmp
PROFILE-*
nohup.out
test.sh
/test
LICENSE.images
src/no_common.h

# submodules
modules/*.c
modules/*.h
21 changes: 12 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
language: c
compiler:
- clang
- gcc-4.4
- gcc-4.5
- gcc-4.6
# - gcc-4.4
# - gcc-4.6
- gcc-4.7
- gcc-4.8
- gcc-4.9
- gcc
- tcc
install:
- sudo apt-get update
- sudo apt-get install gcc-4.4 gcc-4.5 gcc-4.6 chicken-bin tcc
- sudo chicken-install test
# - sudo apt-cache search gcc
- sudo apt-get install gcc-4.7 gcc-4.8 gcc-4.9 tcc
script:
- autoreconf -i
- ./configure --without-gtk2
- ./configure --without-x
- make clean
- make
- src/zbatt || true
- src/zbatc || true
- (src/zbatt; echo -e "\n$?")
- (src/zbatc; echo -e "\n$?")
- make clean
- ./configure --without-gtk2 CFLAGS=-DZB_DEBUG=0
- ./configure --without-x CFLAGS=-DZB_DEBUG=0
- make
after_success:
- make check
4 changes: 2 additions & 2 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@
could mean that using it in a non-GPL'd piece of software might be in violation of its license.
So I was only too pleased when I came across Alexander Peslyak's code and realized that it was Public Domain.

NOTE: Alexander Peslyak does not in any way, shape, or form endorse my use of his code.
NOTE: Alexander Peslyak does not in any way, shape, or form endorse ZBatt.

The version that I used in ZBatt, albeit slightly different, can be found here:
The version that I use(d) in ZBatt, albeit slightly different, can be found here:
"http://openwall.info/wiki/_media/people/solar/software/public-domain-source-code/concat.c"
25 changes: 11 additions & 14 deletions INSTALL
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
Welcome to ZBatt,

# Dependencies

A few dependencies that you'll need:

1. GNU Autotools
2. C99 Compliant C Compiler

Compilers known to work are `gcc', `clang', and `tcc'.
# Building

Unix-like systems, enter the `nix' directory and run:

If you're going to be building the GUI, that is the
graphical frontend for ZBatt, then you'll need:
1. autoreconf -fi
2. ./configure
3. make

1. Cython
2. Python 2.x.x
3. Gtk+ 2.x.x
Windows systems, enter the `win' directory and run:

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

Some configure options worth noting:

@@ -58,6 +53,8 @@ After building ZBatt, install it thusly:

make install

NOTE: you can use `DESTDIR' to specify a particular installation directory.


If you have any problems, find a bug, or would like to provide feedback:
please send an email to <agm2819*gmail*>
99 changes: 89 additions & 10 deletions Makefile.am
Original file line number Diff line number Diff line change
@@ -2,33 +2,112 @@

dist_doc_DATA = LICENSE AUTHORS INSTALL

dist_pkgdata_DATA = example.conf

if MSWIN
MAYBE_MSWIN = src/mswin
else
MAYBE_UNIX = src
if X
MAYBE_X = img
endif
endif

SUBDIRS = $(MAYBE_MSWIN) $(MAYBE_UNIX) $(MAYBE_X)

DIST_SUBDIRS = $(SUBDIRS)

ZB_TARBALL = $$(uname)-$$(uname -m).tar.gz
D2U = dos2unix

all-local:

test-clean:
anew: clean all

test-setup:
mkdir -p test/{ACAD,BAT0,BAT1}
touch test/ACAD/online
touch test/BAT0/capacity
touch test/BAT1/capacity
touch test/BAT0/type
touch test/BAT1/type
touch test/ACAD/type
echo 1 > 'test/ACAD/online'
echo 100 > 'test/BAT0/capacity'
echo 100 > 'test/BAT1/capactiy'
echo 'Battery' > 'test/BAT0/type'
echo 'Battery' > 'test/BAT1/type'
echo 'Mains' > 'test/ACAD/type'

test-onac:
test-clean:
$(RM) -r test

test-onac: test-clean test-setup
echo 1 > 'test/ACAD/online'
$(RM) -r 'test/'{BAT0,BAT1}
$(RM) -r 'test/'{BAT0,BAT1} || $(ERM) -r 'test/'{BAT0,BAT1} || true

test-noac:
test-noac: test-clean test-setup
echo 0 > 'test/ACAD/online'

test-lowbat:
echo 1 > 'test/BAT0/capacity'
echo 1 > 'test/BAT1/capacity'
test-lowbat: test-clean test-setup
echo 10 > 'test/BAT0/capacity'
echo 10 > 'test/BAT1/capacity'

test-empty:
test-empty: test-setup
echo 0 > 'test/BAT0/capacity'
echo 0 > 'test/BAT0/capacity'

test-nosup:
rm -rf 'test/'
$(RM) -r test

test-depth: test-clean
mkdir -p "test"; \
cd "test"; \
for ((idx = 0; idx < 256; ++idx)); do \
mkdir -p "BAT$$idx"; \
cd "BAT$$idx"; \
done; \
echo 50 > "capacity"; \
echo 'Battery' > "type"

test-breadth: test-clean test-setup
cd "test"; \
for ((idx = 0; idx < 256; ++idx)); do \
mkdir -p "BAT$$idx"; \
echo 50 > "BAT$$idx/capacity"; \
echo 'Battery' > "BAT$$idx/type"; \
done

clean-local:
$(RM) -r inst/usr
$(RM) *.tar.gz

release: clean
$(MAKE) DESTDIR="$$PWD/inst" install
cd inst; \
$(RM) $(ZB_TARBALL) ;\
tar czf $(ZB_TARBALL) usr

refresh-check:
cd $(UNIX_DIR); \
$(MAKE) $@

check-all:
cd $(UNIX_DIR); \
$(MAKE) $@

iso:
$(MAKE) dist
genisoimage -o zb.iso *.tar.gz
mv zb.iso ..

SUBDIRS = src img
dos2unix:
$(D2U) $(wildcard src/*)
$(D2U) $(wildcard src/mswin/*)

install-blank:
printf '#include <stdlib.h>\nint main(int argc, char **argv) { return EXIT_SUCCESS; }' > blank.c
$(CC) -o src/zbatt blank.c
$(CC) -o src/zbatc blank.c
cd $(UNIX_DIR); \
$(MAKE) install
97 changes: 75 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,50 +1,100 @@
ZBatt [![Build Status](https://travis-ci.org/amagura/zelda-battery.svg?branch=master)](https://travis-ci.org/amagura/zelda-battery)
ZBatt [![Build Status](https://travis-ci.org/amagura/zelda-battery.svg?branch=master)](https://travis-ci.org/amagura/zelda-battery) [![Circle CI](https://circleci.com/gh/amagura/zelda-battery/tree/master.svg?style=svg)](https://circleci.com/gh/amagura/zelda-battery/tree/master)
=============

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

<!--
* [Supported Platforms](https://github.com/amagura/zelda-battery#supported-platforms)
* [Windows](https://github.com/amagura/zelda-battery#windows)
* [Linux](https://github.com/amagura/zelda-battery#linux)
* [*BSD](https://github.com/amagura/zelda-battery#bsd)
* [Depends](https://github.com/amagura/zelda-battery#dependencies)
* [Make Depends](https://github.com/amagura/zelda-battery#make-dependencies)
* [Building](https://github.com/amagura/zelda-battery#building)
* [Installing](https://github.com/amagura/zelda-battery#installing)
* [Examples](https://github.com/amagura/zelda-battery#examples)
* [Git-esque](https://github.com/amagura/zelda-battery#git-esque)
* [Zsh](https://github.com/amagura/zelda-battery#zsh)
* [Bash](https://github.com/amagura/zelda-battery#bash)
* [Mksh](https://github.com/amagura/zelda-battery#mksh-korn-shell)
* [Tcsh](https://github.com/amagura/zelda-battery#tcsh)
* [Notes](https://github.com/amagura/zelda-battery#notes)
-->
# Supported Platforms
## Linux
Kernels >= 2.6.24 are supported; support for older kernels is not a priority, but may be added later.
### Linux
Kernels >= 2.6.24 are supported; support for older kernels is not a priority.

## *BSD
Most BSDs should be supported: as long as you have `sysctlbyname`, you should be fine. BSD systems known to work:
* DragonFly BSD
### UNIX
BSD is well supported; as long as you have [`sysctlbyname`](http://www.daemon-systems.org/man/sysctlbyname.3.html) 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)

BSD systems that _should_ work:
#### UNIX systems probably supported:
* NetBSD
* Midnight BSD
* OpenSolaris
* (Anything based on FreeBSD)

BSD systems known _not_ to work:
#### UNIX systems unsupported:
* OpenBSD
* SmartOS (Solaris)

### Windows
Windows XP and later.

# Runtime Dependencies
### Linux and UNIX
* Python (GUI)<sup>†</sup>
* GTK+3 (GUI)<sup>‡</sup>
* PyGObject (GUI)

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

### Windows
Windows provides everything you'll need.

### Dependencies (v3.0+)
* GNU Autotools
## Make Dependencies
* GNU Autotools (i.e. automake, autoconf)
* Make

### Linux and UNIX
* C99 compliant C compiler
* Cython (GUI)
* pkgconf (GUI)

The GUI (Graphical User Interface) requires __gtk2__ and the `configure` script will need __pkg-config__, but these are optional, since you can opt out of building GUI using the `--without-gtk2` `configure` flag.
### Windows
* C++11 compliant C++ compiler

### Building
1. `autoreconf -i`
# Building
1. `autoreconf -fi`
2. `./configure`
3. `make`

### Installing
Just place `zbatc` (zbatt-color) and `zbatt` (zbatt-text) where ever you want them and add the appropriate stuff to your terminal prompt.
# 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.

## Styles
### Git
### Git-esque
![example of the git style](/example/git.jpg)
```bash
./zbatc -c 32; ./zbatt -p -f +; ./zbatc -c 31; ./zbatt -m -e -
./zbatc -c 32; ./zbatt -r -f +; ./zbatc -c 31; ./zbatt -x -e -
```


## Shells
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](/example/zsh.jpg)
@@ -54,12 +104,12 @@ PROMPT="%{$(./zbatc)%}$(./zbatt)%{%} %m%# "
## run TRAPALRM every $TMOUT seconds
TMOUT=60 # refresh the terminal prompt every 60 seconds

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


### Bash
![example showing zelda-battery in a Bash prompt](/example/bash.jpg)
```bash
@@ -85,3 +135,6 @@ As long as you use the `TMOUT` and `TRAPALRM`/`zle reset-prompt` stuff, your Zsh

## 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.
Loading