dwm
dynamic window manager
git clone https://9o.is/git/dwm.git
commit ea8c34c2847ded9c917187a53c79f9118d1630cc parent f377abd9a334289a95c26b1cbfb2fb6fdb3fe360 Author: Jul <jul@9o.is> Date: Sun, 1 Feb 2026 20:46:05 -0500 allow window to set status in status bar Diffstat:
| M | dwm.c | | | 24 | ++++++++++++++++++++++-- |
1 file changed, 22 insertions(+), 2 deletions(-)
diff --git a/dwm.c b/dwm.c @@ -65,6 +65,7 @@ enum { NetSupported, NetWMName, NetWMState, NetWMCheck, NetWMWindowTypeDialog, NetClientList, NetClientInfo, NetLast }; /* EWMH atoms */ enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */ enum { QubesVMName, QubesLast }; /* Qubes atoms */ +enum { MyStatus, MyLast }; /* My atoms */ enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkCounter, ClkClientWin, ClkRootWin, ClkLast }; /* clicks */ @@ -88,6 +89,7 @@ typedef struct Client Client; struct Client { char vmname[256]; char name[256]; + char mystatus[256]; float mina, maxa; int x, y, w, h; int oldx, oldy, oldw, oldh; @@ -268,7 +270,7 @@ static void (*handler[LASTEvent]) (XEvent *) = { [PropertyNotify] = propertynotify, [UnmapNotify] = unmapnotify }; -static Atom wmatom[WMLast], netatom[NetLast], qubesatom[QubesLast]; +static Atom wmatom[WMLast], netatom[NetLast], qubesatom[QubesLast], myatom[MyLast]; static int restart = 0; static int running = 1; static Cur *cursor[CurLast]; @@ -773,12 +775,18 @@ drawbar(Monitor *m) tw += TEXTW(m->ccounter); tw += TEXTW(m->ltsymbol); + for (i = 0; i < LENGTH(tags); i++) { if(!(occ & 1 << i || m->tagset[m->seltags] & 1 << i)) continue; tw += TEXTWNP(tags[i]); } + if (m->sel && m->sel->mystatus[0] != '\0') { + tw += TEXTW(m->sel->mystatus); + tw += TEXTW("«"); + } + x = 0; if (m->sel) { @@ -798,6 +806,13 @@ drawbar(Monitor *m) x += w; } + if (m->sel && m->sel->mystatus[0] != '\0') { + w = TEXTW(m->sel->mystatus); + x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->mystatus, 0); + w = TEXTW("«"); + x = drw_text(drw, x, 0, w, bh, lrpad / 2, "«", 0); + } + w = TEXTW(m->ccounter); x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ccounter, 0); @@ -1324,7 +1339,8 @@ propertynotify(XEvent *e) drawbars(); break; } - if (ev->atom == XA_WM_NAME || ev->atom == netatom[NetWMName] || ev->atom == qubesatom[QubesVMName]) { + if (ev->atom == XA_WM_NAME || ev->atom == netatom[NetWMName] || + ev->atom == qubesatom[QubesVMName] || ev->atom == myatom[MyStatus]) { updatetitle(c); if (c == c->mon->sel) drawbar(c->mon); @@ -1681,6 +1697,8 @@ setup(void) netatom[NetClientInfo] = XInternAtom(dpy, "_NET_CLIENT_INFO", False); /* init qubes atoms */ qubesatom[QubesVMName] = XInternAtom(dpy, "_QUBES_VMNAME", False); + /* init my atoms */ + myatom[MyStatus] = XInternAtom(dpy, "_MY_WIN_STATUS", False); /* init cursors */ cursor[CurNormal] = drw_cur_create(drw, XC_left_ptr); cursor[CurResize] = drw_cur_create(drw, XC_sizing); @@ -2146,6 +2164,8 @@ updatetitle(Client *c) { if (!gettextprop(c->win, qubesatom[QubesVMName], c->vmname, sizeof c->vmname)) snprintf(c->vmname, sizeof(c->vmname), "%s", gui_domain); + if (!gettextprop(c->win, myatom[MyStatus], c->mystatus, sizeof c->mystatus)) + strcpy(c->mystatus, ""); if (!gettextprop(c->win, netatom[NetWMName], c->name, sizeof c->name)) gettextprop(c->win, XA_WM_NAME, c->name, sizeof c->name); if (c->name[0] == '\0') /* hack to mark broken clients */