barbar – lightweight customizable desktop status bar

About
barbar is a little tool to create a status line for several lightweight window managers, LCDs or text consoles. The idea was born when we switched from KDE / GNOME to wmii and found the naive way of creating the status line (running multiple programs, piping stuff through cut, awk or sed, …) rather lame.

Some boring Friday night with lots of beer and little else to do, this project was born.

barbar gathers data from the /proc and /sys filesystem without the need for external tools. Its output format, including the selection of data modules to be used, is set through command line arguments. It writes everything to stdout periodically.

Installation
For now, I can just tell you to run make and hope that it works. Put it wherever you want.

Usage
barbar -help should give you some idea on how to set the command line.
Every module has an optional title – this is what’s displayed right in front of the data from the modules. Leave it out if you don’t want a title.
These are the modules:

  • cpu – Shows CPU usage. For multiprocessor systems, you can set the name to CPU0, CPU1 and so on for stats on each core or just CPU to get a summary. This grabs its data from /proc/stat
  • freq – The clock frequency of your CPU. The name selects which core to check. It looks at /sys/devices/system/cpu/[NAME]/cpufreq/scaling_cur_freq to get its data. If you don’t have those files, check if you have the kernel module cpufreq loaded.
  • net – Network bandwith usage and IP adress of the iface you specify. For now, only the sum of received and transmitted bytes is displayed. Data is gathered from /sys/class/net/[IFACE]/statistics{rx_bytes,tx_bytes,carrier}.
  • battery – Battery charge, and time until empty / full. A little + or – in front of the time indicates whether the battery is charging or discharging. If neither is the case, no time is displayed. The name should be BAT0 unless you have multiple batteries. The module gets its readings from /sys/bus/acpi/drivers/battery/PNP0C0A:00/power_supply/. The files used are charge_full, charge_now (if it does not find those, it uses energy_full and energy_now), status and current_now (to find out the remaining time).
  • clock – A clock. You can customize how it displays the time throug the format parameter. Defaults to %H:%M:%S. If you are unsure on how to get it to display what you want, consult man strftime.

Here’s an example command line:
barbar -battery bat0 Bat -net wlan0 Net -cpu cpu0 CPU -freq cpu0 -clock "%H:%M %a %d.%m.%y"
Its output looks like this on my system:
Bat: 98% [|||||||||-] (- 2:42) | Net: 0kB/s [10.0.1.238] | CPU: 5%usr 0%sys 84%idl | 800 MHz | 22:29 Sun 14.02.10

We also included barbarbar.sh which uses wmiir to display barbar’s output in your wmii status bar. Just add something like
barbarbar.sh -battery bat0 Bat -net wlan0 Net -cpu cpu0 CPU -freq cpu0 -clock "%H:%M %a %d.%m.%y" &
near the end of your wmiirc.

This is what it looks like in my wmii bar:
barbarbar wmii screenshot
Click to see full size.

Get the source here: barbar.tar.gz (4~8kB depending on who you ask) – Distributed under GPL.

The future
Planned features for future releases include:

  • Make nice-looking graphics for dzen2
  • Show up / down traffic separately for network interfaces
  • CPU / Hard drive temperature information, fan speeds
  • Memory usage

Feel free to report problems or request features in the comments. We appreciate your feedback.