feat: dwm bar #10

Open
opened 2026-08-15 09:48:04 +02:00 by doom · 6 comments
Owner
  • add time [1s]
  • add weather [30m/1h]
  • add daily reminders
    • connect with WaniKani API [10m/end-of-day]
- [x] add time [1s] - [ ] add weather [30m/1h] - [ ] add daily reminders - [ ] connect with WaniKani API [10m/end-of-day]
doom self-assigned this 2026-08-15 09:48:04 +02:00
doom added this to the OS Maintenance project 2026-08-15 09:48:04 +02:00
Author
Owner

dwm.c:711 contains a

drw_setscheme(drw, scheme[SchemeNorm]);

when rendering the bar, that's good news, since we can probably set a general colorscheme for everything dwm!

`dwm.c:711` contains a ```c drw_setscheme(drw, scheme[SchemeNorm]); ``` when rendering the bar, that's good news, since we can probably set a general colorscheme for everything dwm!
Author
Owner

This looks like the function that draws the workspace-selector part of the bar:

	for (i = 0; i < LENGTH(tags); i++) {
		w = TEXTW(tags[i]);
		drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
		drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i);
		if (occ & 1 << i)
			drw_rect(drw, x + boxs, boxs, boxw, boxw,
				m == selmon && selmon->sel && selmon->sel->tags & 1 << i,
				urg & 1 << i);
		x += w;
	}

That would, presumably, imply that tags controls the text that gets in there!

Pretty sure that this sets & subsequently draws the layout symbol:

w = TEXTW(m->ltsymbol);

dwm.c:732

This looks like the function that draws the workspace-selector part of the bar: ```c for (i = 0; i < LENGTH(tags); i++) { w = TEXTW(tags[i]); drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]); drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i); if (occ & 1 << i) drw_rect(drw, x + boxs, boxs, boxw, boxw, m == selmon && selmon->sel && selmon->sel->tags & 1 << i, urg & 1 << i); x += w; } ``` That would, presumably, imply that `tags` controls the text that gets in there! Pretty sure that this sets & subsequently draws the layout symbol: ```c w = TEXTW(m->ltsymbol); ``` `dwm.c:732`
Author
Owner

All of the bars work by setting the "root title" via:

xsetroot -name "$barstring"

This appears to work via the rendering here:

	/* draw status first so it can be overdrawn by tags later */
	if (m == selmon) { /* status is only drawn on selected monitor */
		drw_setscheme(drw, scheme[SchemeNorm]);
		tw = TEXTW(stext) - lrpad + 2; /* 2px right padding */
		drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0);
	}

which pulls the data from:

void
updatestatus(void)
{
	if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext)))
		strcpy(stext, "dwm-"VERSION);
	drawbar(selmon);
}

Why by default simply writes the dwm-${VERSION}...

That is called on:

// Property Update (L1229)
	if ((ev->window == root) && (ev->atom == XA_WM_NAME))
		updatestatus();
// Setup (L1592)
	updatestatus();

All of the bars work by setting the "root title" via: ```sh xsetroot -name "$barstring" ``` This appears to work via the rendering here: ```c /* draw status first so it can be overdrawn by tags later */ if (m == selmon) { /* status is only drawn on selected monitor */ drw_setscheme(drw, scheme[SchemeNorm]); tw = TEXTW(stext) - lrpad + 2; /* 2px right padding */ drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0); } ``` which pulls the data from: ```c void updatestatus(void) { if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext))) strcpy(stext, "dwm-"VERSION); drawbar(selmon); } ``` Why by default simply writes the `dwm-${VERSION}`... That is called on: ```c // Property Update (L1229) if ((ev->window == root) && (ev->atom == XA_WM_NAME)) updatestatus(); // Setup (L1592) updatestatus(); ```
Author
Owner

Added a clock to the bar in 48703e463f

Added a clock to the bar in 48703e463f
Author
Owner

As far as I understood, coloring the bar in a custom way requires a custom patch that processes color variables that get passed as text.

Something that could be a patch for that can be found here:
https://github.com/Haini/dwm/blob/master/statuscolors.diff

The script I referenced for inspiration in #3 (https://github.com/ab9il/dwm-bar) uses \^c(?<color>#[a-f0-9]{,6})\^ for colors for example. Unfortunately, it does not reference any patches (other than extra-bar that could help identifying how the color parsing is done)

As far as I understood, coloring the bar in a custom way requires a custom patch that processes color variables that get passed as text. Something that could be a patch for that can be found here: https://github.com/Haini/dwm/blob/master/statuscolors.diff The script I referenced for inspiration in #3 (https://github.com/ab9il/dwm-bar) uses `\^c(?<color>#[a-f0-9]{,6})\^` for colors for example. Unfortunately, it does not reference any patches (other than `extra-bar` that could help identifying how the color parsing is done)
Author
Owner

Another thing would be to embed the status of sshd on the bar.
Offline/[listening-interface] (e.g. 100.64.0.9)

Another thing would be to embed the status of `sshd` on the bar. `Offline`/`[listening-interface]` (e.g. `100.64.0.9`)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
doom/Mu#10
No description provided.