Go to file
Gaël PORTAY 0b8aa86ecb print_cpu_usage: fix invalid %cpu placeholder output
Currently, the module cpu_usage prints %cpu0 information for the invalid
%cpu placeholder (i.e. the cpu number is missing).

Consider the following configuration.

	order += "cpu_usage"

	cpu_usage {
		format = "cpu0=%cpu0 cpu1=%cpu1 cpu=%cpu"
		# missing cpu number -------------------^
	}

The configuration above produces the output below.

	$ i3status -c config
	i3status: trying to auto-detect output_format setting
	i3status: auto-detected "term"
	cpu0=-2% cpu1=-49% cpu=-2%
	cpu0=06% cpu1=02% cpu=06%
	cpu0=05% cpu1=06% cpu=05%
	...

The module prints %cpu0 at the third placeholder where it should report
an error.

This commit fixes this behavior by initializing `number' to -1. If the
cpu is missing in %cpu placeholder, the sscanf function does not set
`number'. Because `number' is -1 (lower to 0), an error is reported and
the placeholder is skipped.

	$ i3status -c ./config
	i3status: trying to auto-detect output_format setting
	i3status: auto-detected "term"
	provided CPU number '-1' above detected number of CPU 4
	cpu0= cpu1=-48% cpu=
	provided CPU number '-1' above detected number of CPU 4
	cpu0= cpu1=11% cpu=
	provided CPU number '-1' above detected number of CPU 4
	cpu0= cpu1=03% cpu=
	...
2018-10-21 20:51:53 -04:00
contrib Consolidate measure speed script (#188) 2017-01-02 16:06:06 +01:00
include fix clang errors 2018-07-13 15:11:43 +02:00
man man: fix typo for max_threshold in load 2018-10-18 17:29:21 -04:00
src print_cpu_usage: fix invalid %cpu placeholder output 2018-10-21 20:51:53 -04:00
testcases Add testcase for #304 2018-09-03 20:51:48 +02:00
travis Show differing results, if testcase fails 2018-06-19 17:17:51 +02:00
yajl-fallback/yajl add yajl compat code 2012-04-08 14:05:47 +02:00
.clang-format switch to clang 3.8 & ignore sort oder of includes 2018-07-08 13:48:28 +02:00
.gitignore Add i3status and man/i3status.1 to ignore list. 2015-02-07 22:17:59 -02:00
.travis.yml switch to clang 3.8 & ignore sort oder of includes 2018-07-08 13:48:28 +02:00
CHANGELOG release v2.12 2018-05-11 11:07:22 +02:00
CONTRIBUTING.md add CONTRIBUTING file 2015-03-16 10:02:22 +01:00
i3status.c strncpy + strlen is pointless (#312) 2018-10-07 20:26:24 +02:00
i3status.conf Stop requiring CAP_NET_ADMIN 2018-06-25 11:53:05 +02:00
I3STATUS_VERSION release v2.12 2018-05-11 11:07:22 +02:00
LICENSE Separate license into file LICENSE 2009-10-15 20:44:24 +02:00
Makefile Do not use pulseaudio for DragonFly BSD 2018-07-14 20:23:22 +00:00
README.md Stop requiring CAP_NET_ADMIN 2018-06-25 11:53:05 +02: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
  • 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 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