|
3
|
1 From c0e147bf031f9c2638e2c192a97e2d200e4b74be Mon Sep 17 00:00:00 2001 |
|
|
2 From: Rizqi Nur Assyaufi <bandithijo@gmail.com> |
|
|
3 Date: Fri, 15 Aug 2025 20:49:26 +0800 |
|
|
4 Subject: [PATCH] Add DWM logo on left bar before tags |
|
|
5 |
|
|
6 This patch adds a DWM logo to the left side of the status bar, positioned |
|
|
7 before the tags, for aesthetic or branding purposes. |
|
|
8 |
|
|
9 Defines a fixed logo width (`dwmlogowdth = 54`) and adjusts tag rendering to |
|
|
10 prevent overlap. |
|
|
11 |
|
|
12 Uses multiple `drw_rect()` calls to render a pixel-art style "dwm" logo using |
|
|
13 rectangles. |
|
|
14 |
|
|
15 This patch is purely visual and does not impact DWM's core functionality or |
|
|
16 performance. It may appeal to users who want a more personalized or distinctive |
|
|
17 appearance for their window manager. |
|
|
18 |
|
|
19 --- |
|
|
20 dwm.c | 34 +++++++++++++++++++++++++++++++++- |
|
|
21 1 file changed, 33 insertions(+), 1 deletion(-) |
|
|
22 |
|
|
23 diff --git a/dwm.c b/dwm.c |
|
|
24 index 1443802..c9b2858 100644 |
|
|
25 --- a/dwm.c |
|
|
26 +++ b/dwm.c |
|
|
27 @@ -140,6 +140,10 @@ typedef struct { |
|
|
28 int monitor; |
|
|
29 } Rule; |
|
|
30 |
|
|
31 +typedef struct { |
|
|
32 + int x, y, w, h; |
|
|
33 +} DwmLogo; |
|
|
34 + |
|
|
35 /* function declarations */ |
|
|
36 static void applyrules(Client *c); |
|
|
37 static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact); |
|
|
38 @@ -240,6 +244,7 @@ static int screen; |
|
|
39 static int sw, sh; /* X display screen geometry width, height */ |
|
|
40 static int bh; /* bar height */ |
|
|
41 static int lrpad; /* sum of left and right padding for text */ |
|
|
42 +static int dwmlogowdth = 54; /* dwm logo width */ |
|
|
43 static int (*xerrorxlib)(Display *, XErrorEvent *); |
|
|
44 static unsigned int numlockmask = 0; |
|
|
45 static void (*handler[LASTEvent]) (XEvent *) = { |
|
|
46 @@ -432,6 +437,7 @@ buttonpress(XEvent *e) |
|
|
47 } |
|
|
48 if (ev->window == selmon->barwin) { |
|
|
49 i = x = 0; |
|
|
50 + x = dwmlogowdth; /* dwm logo width */ |
|
|
51 do |
|
|
52 x += TEXTW(tags[i]); |
|
|
53 while (ev->x >= x && ++i < LENGTH(tags)); |
|
|
54 @@ -698,6 +704,7 @@ void |
|
|
55 drawbar(Monitor *m) |
|
|
56 { |
|
|
57 int x, w, tw = 0; |
|
|
58 + int stroke = 4, letterHeight = bh - 4; |
|
|
59 int boxs = drw->fonts->h / 9; |
|
|
60 int boxw = drw->fonts->h / 6 + 2; |
|
|
61 unsigned int i, occ = 0, urg = 0; |
|
|
62 @@ -718,7 +725,32 @@ drawbar(Monitor *m) |
|
|
63 if (c->isurgent) |
|
|
64 urg |= c->tags; |
|
|
65 } |
|
|
66 - x = 0; |
|
|
67 + |
|
|
68 + /* use colored scheme for visibility */ |
|
|
69 + drw_setscheme(drw, scheme[SchemeNorm]); |
|
|
70 + |
|
|
71 + /* draw dark background for logo */ |
|
|
72 + drw_rect(drw, 0, 0, dwmlogowdth, bh, 1, 1); |
|
|
73 + |
|
|
74 + /* draw dwm logo */ |
|
|
75 + const DwmLogo dwmLogo[] = { |
|
|
76 + { 0, 9, stroke, letterHeight / 2 }, /* d: left vertical */ |
|
|
77 + { 0, 15, 35, stroke }, /* d: bottom horizontal */ |
|
|
78 + { 13, 1, stroke, letterHeight }, /* d: right vertical */ |
|
|
79 + { 0, 7, 15, stroke }, /* d: top horizontal */ |
|
|
80 + { 22, 7, stroke, letterHeight / 2 }, /* w: center vertical */ |
|
|
81 + { 31, 7, stroke, letterHeight / 2 }, /* w: right vertical */ |
|
|
82 + { 31, 7, 22, stroke }, /* m: top horizontal */ |
|
|
83 + { 40, 11, stroke, letterHeight / 2 }, /* m: center vertical */ |
|
|
84 + { 49, 11, stroke, letterHeight / 2 } /* m: right vertical */ |
|
|
85 + }; |
|
|
86 + |
|
|
87 + for (int i = 0; i < LENGTH(dwmLogo); i++) { |
|
|
88 + drw_rect(drw, dwmLogo[i].x, dwmLogo[i].y, dwmLogo[i].w, dwmLogo[i].h, 1, 0); |
|
|
89 + } |
|
|
90 + |
|
|
91 + /* start drawing tags after logo */ |
|
|
92 + x = dwmlogowdth; |
|
|
93 for (i = 0; i < LENGTH(tags); i++) { |
|
|
94 w = TEXTW(tags[i]); |
|
|
95 drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]); |
|
|
96 -- |
|
|
97 2.50.1 |
|
|
98 |