Go to file
johcgt d5c69a9d60 Treat zero battery capacity as "not available" (#259)
`print_battery_info` computes `batt_info.percentage_remaining` by
dividing batt_info.remaining by `full`. If `full` is `0` then the
battery remaining will be reported as "inf".

Before this, it tries to set `full` to either the design capacity or to
the last known good charge. It determines if these values are available
by checking whether their fields in `batt_info` are non-negative. As it
initialized `batt_info` with values of `-1`, a non-negative value
implies that something has provided a value.

`slurp_all_batteries` and `add_battery_info` however initialize these
fields to zero, so if these functions are called then
`batt_info.full_design` will always be used.

This means that on systems that don't provide a value for design
capacity the percentage remaining will be reported as "inf", unless the
user has set `last_full_capacity` to `true` in their `i3status.conf`.

This patch changes `print_battery_info` to expect values for the battery
capacity to be strictly greater than zero. This seems reasonable as a
battery with a capacity of zero isn't useful.

An alternative solution would be to change `slurp_all_batteries` and
`add_battery_info` to initialize `batt_info` with `-1`, as
`print_battery_info` does. This is less appealing as `add_battery_info`
is accumulating the values, so using `-1` would introduce off-by-one
errors without additional code to avoid them.
2018-01-28 15:37:51 +01:00
contrib Consolidate measure speed script (#188) 2017-01-02 16:06:06 +01:00
include Add IPv6 address when IPv4 isn't available (#247) 2017-12-11 11:38:31 +01:00
man Add IPv6 address when IPv4 isn't available (#247) 2017-12-11 11:38:31 +01:00
src Treat zero battery capacity as "not available" (#259) 2018-01-28 15:37:51 +01:00
testcases Treat zero battery capacity as "not available" (#259) 2018-01-28 15:37:51 +01:00
travis Fix CPU unit tests (#239) 2017-08-29 19:01:30 +02:00
yajl-fallback/yajl add yajl compat code 2012-04-08 14:05:47 +02:00
.clang-format clang-format-3.5 -i **/*.[ch], update modeline 2015-03-16 10:01:07 +01:00
.gitignore Add i3status and man/i3status.1 to ignore list. 2015-02-07 22:17:59 -02:00
.travis.yml Unit testing in Travis (#170) 2016-11-14 00:13:44 -08:00
CHANGELOG release v2.11 2017-01-21 16:00:15 +01:00
CONTRIBUTING.md add CONTRIBUTING file 2015-03-16 10:02:22 +01:00
i3status.c Add IPv6 address when IPv4 isn't available (#247) 2017-12-11 11:38:31 +01:00
i3status.conf Implement aggregates for batteries. 2016-08-28 14:29:08 +01:00
I3STATUS_VERSION release v2.11 2017-01-21 16:00:15 +01:00
LICENSE Separate license into file LICENSE 2009-10-15 20:44:24 +02:00
Makefile Makefile: make PKG_CONFIG overridable (patch by Helmut Grohne) 2017-09-18 08:30:48 +02:00
README.md Get rid of the SLOC comment 2017-12-11 22:50:16 +01:00

i3status

Description

i3status is a small program for generating a status bar for i3bar, dzen2, xmobar or similar programs. It is designed to be very efficient by issuing a very small number of system calls, as one generally wants to update such a status line every second. This ensures that even under high load, your status bar is updated correctly. Also, it saves a bit of energy by not hogging your CPU as much as spawning the corresponding amount of shell commands would.

Development

i3status has the following dependencies:

  • libconfuse-dev
  • libyajl-dev
  • libasound2-dev
  • libnl-genl-3-dev
  • libcap2-bin (for getting network status without root permissions)
  • asciidoc (only for the documentation)
  • libpulse-dev (for getting the current volume using PulseAudio)

On debian-based systems, the following line will install all requirements:

apt-get install libconfuse-dev libyajl-dev libasound2-dev libiw-dev asciidoc libcap2-bin libpulse-dev libnl-genl-3-dev

Upstream

i3status is developed at https://github.com/i3/i3status

Compilation

Compiling is done with the usual make-line

  make && sudo make install