sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

dwm-bardwmlogo-6.5.diff (2985B)


      1 From 22f1116ed0d9a499a73394eb42f1e0d51fd4f2fc Mon Sep 17 00:00:00 2001
      2 From: Rizqi Nur Assyaufi <bandithijo@gmail.com>
      3 Date: Tue, 24 Jun 2025 22:56:04 +0800
      4 Subject: [PATCH] Add DWM logo on left bar before tags
      5 
      6 This patch add dwm logo before tags on the left side of the status bar for
      7 aesthetic or branding purposes.
      8 
      9 The logo renders using several ractangels to form the characters "dwm" in a
     10 pixel-art style.
     11 ---
     12  dwm.c | 34 +++++++++++++++++++++++++++++++++-
     13  1 file changed, 33 insertions(+), 1 deletion(-)
     14 
     15 diff --git a/dwm.c b/dwm.c
     16 index f1d86b2..0bef187 100644
     17 --- a/dwm.c
     18 +++ b/dwm.c
     19 @@ -141,6 +141,10 @@ typedef struct {
     20  	int monitor;
     21  } Rule;
     22  
     23 +typedef struct {
     24 +	int x, y, w, h;
     25 +} DwmLogo;
     26 +
     27  /* function declarations */
     28  static void applyrules(Client *c);
     29  static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact);
     30 @@ -241,6 +245,7 @@ static int screen;
     31  static int sw, sh;           /* X display screen geometry width, height */
     32  static int bh;               /* bar height */
     33  static int lrpad;            /* sum of left and right padding for text */
     34 +static int dwmlogowdth = 54; /* dwm logo width */
     35  static int (*xerrorxlib)(Display *, XErrorEvent *);
     36  static unsigned int numlockmask = 0;
     37  static void (*handler[LASTEvent]) (XEvent *) = {
     38 @@ -433,6 +438,7 @@ buttonpress(XEvent *e)
     39  	}
     40  	if (ev->window == selmon->barwin) {
     41  		i = x = 0;
     42 +		x = dwmlogowdth; /* dwm logo width */
     43  		do
     44  			x += TEXTW(tags[i]);
     45  		while (ev->x >= x && ++i < LENGTH(tags));
     46 @@ -699,6 +705,7 @@ void
     47  drawbar(Monitor *m)
     48  {
     49  	int x, w, tw = 0;
     50 +	int stroke = 4, letterHeight = bh - 4;
     51  	int boxs = drw->fonts->h / 9;
     52  	int boxw = drw->fonts->h / 6 + 2;
     53  	unsigned int i, occ = 0, urg = 0;
     54 @@ -719,7 +726,32 @@ drawbar(Monitor *m)
     55  		if (c->isurgent)
     56  			urg |= c->tags;
     57  	}
     58 -	x = 0;
     59 +
     60 +	/* use colored scheme for visibility */
     61 +	drw_setscheme(drw, scheme[SchemeNorm]);
     62 +
     63 +	/* draw dark background for logo */
     64 +	drw_rect(drw, 0, 0, dwmlogowdth, bh, 1, 1);
     65 +
     66 +	/* draw dwm logo */
     67 +	const DwmLogo dwmLogo[] = {
     68 +		{  0,  9, stroke, letterHeight / 2 }, /* d: left vertical */
     69 +		{  0, 15,     35, stroke           }, /* d: bottom horizontal */
     70 +		{ 13,  1, stroke, letterHeight     }, /* d: right vertical */
     71 +		{  0,  7,     15, stroke           }, /* d: top horizontal */
     72 +		{ 22,  7, stroke, letterHeight / 2 }, /* w: center vertical */
     73 +		{ 31,  7, stroke, letterHeight / 2 }, /* w: right vertical */
     74 +		{ 31,  7,     22, stroke           }, /* m: top horizontal */
     75 +		{ 40, 11, stroke, letterHeight / 2 }, /* m: center vertical */
     76 +		{ 49, 11, stroke, letterHeight / 2 }  /* m: right vertical */
     77 +	};
     78 +
     79 +	for (int i = 0; i < LENGTH(dwmLogo); i++) {
     80 +		drw_rect(drw, dwmLogo[i].x, dwmLogo[i].y, dwmLogo[i].w, dwmLogo[i].h, 1, 0);
     81 +	}
     82 +
     83 +	/* start drawing tags after logo */
     84 +	x = dwmlogowdth;
     85  	for (i = 0; i < LENGTH(tags); i++) {
     86  		w = TEXTW(tags[i]);
     87  		drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
     88 -- 
     89 2.50.0
     90