This is a dirty-hack for the scrotwm window manager that enables the text displayed in the bar to be color-ized using a simple markup language. See below for a screenshot.
With this hack added to scrotwm, the text-output from the bar_application will be displayed verbatim in the display using the bar_color specified in your .scrotwm.conf (just as it normally is), with the following 3 exceptions:
Suppose that bar_color is set to white. Then the following text, output by the bar_application,
"Hello #ff0000#world##! My #00ff00#name## is #0000ff#Simon##."would be displayed in the actual bar as
Hello world! My name is Simon.
Requisite screenshot. Click to enlarge. The bar is at the top.
The text being shown in the bar is a list of users logged into two machines, queried using finger(1). The server names are in magenta, and the user names are color-coded by how long they have been idle. The number of sessions of each user is printed after their name. (Note that the minimum idle time of any users' sessions is what's used).
Here: color_bar.c Tested and works great on scrotwm-0.9.5 through scrotwm-0.9.20.
Note that I am not providing patches for each snapshot/release. I will once development of scrowm settles down.
Integrating it into the scrotwm source file is rather straight-forward.
void
bar_print(struct swm_region *r, char *s)
{
XClearWindow(display, r->bar_window);
XSetForeground(display, bar_gc, r->s->c[SWM_S_COLOR_BAR_FONT].color);
XDrawString(display, r->bar_window, bar_gc, 4, bar_fs->ascent, s,
strlen(s));
}
with this...
#include "color_bar.c" void bar_print(struct swm_region *r, char *s) { XClearWindow(display, r->bar_window); XSetForeground(display, bar_gc, r->s->c[SWM_S_COLOR_BAR_FONT].color); color_bar_draw_markup(r->bar_window, 4, bar_fs->ascent, r->s->c[SWM_S_COLOR_BAR_FONT].color, s, strlen(s)); XSetForeground(display, bar_gc, r->s->c[SWM_S_COLOR_BAR_FONT].color); }
The output you see in the screenshot above in the bar is generated from this program: myfinger.c
When compiled, running myfinger hostname will query using finger(1) the provided host and output to stdout a list of all users logged in, in the form usernameX where X denotes the number of login sessions for the given user, and username is colored (using the markup described above) as follows: active (0 idle time) is green, ≤ 10 minutes idle is yellow, and if older the color is red, with decreasing brightness (i.e. from #ff0000 to #660000).
The bar_action script I use to generat the output is: scrotwm-baraction.sh.