2013-10-02 · in Tech Notes · 190 words

This is termbar:

Screenshot of termbar

It's an unobtrusive system monitor for X, along the lines of dzen, but it's implemented in an unusual way: it's just a small rxvt-unicode terminal window, running the termbar program.

The terminal is invoked with the -name TermBar option to distinguish it from other terminals, and with an appropriate -geometry to set the size and position.

The Openbox window manager is configured to keep it above other windows, without the usual decorations:

<application name="TermBar">
  <decor>no</decor>
  <desktop>all</desktop>
  <layer>above</layer>
  <skip_pager>yes</skip_pager>
  <skip_taskbar>yes</skip_taskbar>
</application>

The program running in the terminal can, of course, display anything it likes. termbar uses ncurses to show a Teletext-style clock, and the CPU load as a series of bars drawn using Unicode box-drawing characters, sorted so that it fills up from right to left. It can even respond to mouse clicks — e.g. to lock the display when it's right-clicked on, a feature inspired by enh's clock.

One subtlety when using ncurses to produce this kind of display is that you can't use addstr to print in the bottom right corner (presumably because it would leave the cursor off the screen) — you need to use insstr instead.