show X root window name in spot1 title for a custom status bar

This commit is contained in:
Sean Pringle
2013-04-27 23:06:16 +10:00
parent ed2fb6f96b
commit f99ebf1d04
5 changed files with 18 additions and 3 deletions

View File

@@ -128,7 +128,7 @@ binding keys[] = {
// Only works for apps that use some form of their binary name as their class...
{ .mod = AnyModifier, .key = XK_F1, .act = action_find_or_start, .data = "konsole" },
{ .mod = AnyModifier, .key = XK_F2, .act = action_find_or_start, .data = "chromium" },
{ .mod = AnyModifier, .key = XK_F3, .act = action_find_or_start, .data = "pcmanfm" },
{ .mod = AnyModifier, .key = XK_F3, .act = action_find_or_start, .data = "thunar" },
{ .mod = AnyModifier, .key = XK_Menu, .act = action_command, .data = "xowl" },
};

View File

@@ -179,6 +179,12 @@ void property_notify(XEvent *ev)
XPropertyEvent *e = &ev->xproperty;
client *c = window_build_client(e->window);
if (e->window == root && e->atom == atoms[WM_NAME])
{
// root name appears in SPOT1 bar, for status etc
update_bars();
}
else
if (c && c->visible && c->manage)
{
client_update_border(c);

View File

@@ -150,7 +150,7 @@ void setup()
}
// become the window manager
XSelectInput(display, root, StructureNotifyMask | SubstructureRedirectMask | SubstructureNotifyMask);
XSelectInput(display, root, PropertyChangeMask | StructureNotifyMask | SubstructureRedirectMask | SubstructureNotifyMask);
// ewmh support
unsigned long pid = getpid();

9
spot.c
View File

@@ -32,6 +32,15 @@ void spot_update_bar(int spot, int mon)
char title[SPOT_BUFF]; *title = 0;
monitor *m = &monitors[mon];
if (spot == SPOT1)
{
// Show X root window name in spot1 bar
// Use xsetroot -name for a custom status
char *tmp = NULL;
if (XFetchName(display, root, &tmp))
len += snprintf(title+len, MAX(0, SPOT_BUFF-len), " %s ", tmp);
if (tmp) XFree(tmp);
}
for_windows(i, o) if (o->manage && o->spot == spot && o->monitor == mon)
{
if (!c) c = o;

2
xoat.1
View File

@@ -1,4 +1,4 @@
.TH XOAT 1 ""
.TH XOAT 1 ""
.SH NAME
.PP
xoat - X11 Obstinate Asymmetric Tiler