dwm-statusbarfont-6.4.diff (7850B)
1 diff -up /dwm-6.4/config.def.h ./config.def.h 2 --- /dwm-6.4/config.def.h 2022-10-04 19:38:18.000000000 +0200 3 +++ ./config.def.h 2023-12-18 11:31:12.178928718 +0100 4 @@ -5,7 +5,11 @@ static const unsigned int borderpx = 1; 5 static const unsigned int snap = 32; /* snap pixel */ 6 static const int showbar = 1; /* 0 means no bar */ 7 static const int topbar = 1; /* 0 means bottom bar */ 8 -static const char *fonts[] = { "monospace:size=10" }; 9 +static const char *fonts[] = { 10 + "monospace:size=10", 11 + "symbola:size=10:antialias=true:autohint=truAe", 12 + "monospace:size=8:antialias=true:autohint=true" 13 + }; 14 static const char dmenufont[] = "monospace:size=10"; 15 static const char col_gray1[] = "#222222"; 16 static const char col_gray2[] = "#444444"; 17 @@ -17,7 +21,9 @@ static const char *colors[][3] = { 18 [SchemeNorm] = { col_gray3, col_gray1, col_gray2 }, 19 [SchemeSel] = { col_gray4, col_cyan, col_cyan }, 20 }; 21 - 22 +/* Select the font index for you statusbar 23 + * the index is zero based*/ 24 +static const int statusfontindex = 2; 25 /* tagging */ 26 static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; 27 28 Only in .: config.h 29 diff -up /dwm-6.4/drw.c ./drw.c 30 --- /dwm-6.4/drw.c 2022-10-04 19:38:18.000000000 +0200 31 +++ ./drw.c 2023-12-18 11:20:02.648918951 +0100 32 @@ -236,7 +236,7 @@ drw_rect(Drw *drw, int x, int y, unsigne 33 } 34 35 int 36 -drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert) 37 +drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert, int statusfontindex ) 38 { 39 int i, ty, ellipsis_x = 0; 40 unsigned int tmpw, ew, ellipsis_w = 0, ellipsis_len; 41 @@ -272,14 +272,16 @@ drw_text(Drw *drw, int x, int y, unsigne 42 43 usedfont = drw->fonts; 44 if (!ellipsis_width && render) 45 - ellipsis_width = drw_fontset_getwidth(drw, "..."); 46 + ellipsis_width = drw_fontset_getwidth(drw, "...",0); 47 while (1) { 48 ew = ellipsis_len = utf8strlen = 0; 49 utf8str = text; 50 nextfont = NULL; 51 while (*text) { 52 utf8charlen = utf8decode(text, &utf8codepoint, UTF_SIZ); 53 - for (curfont = drw->fonts; curfont; curfont = curfont->next) { 54 + curfont = drw->fonts; 55 + for (int i=0;i<statusfontindex;i++) {curfont = curfont->next;} 56 + for (; curfont; curfont = curfont->next) { 57 charexists = charexists || XftCharExists(drw->dpy, curfont->xfont, utf8codepoint); 58 if (charexists) { 59 drw_font_getexts(curfont, text, utf8charlen, &tmpw, NULL); 60 @@ -326,7 +328,7 @@ drw_text(Drw *drw, int x, int y, unsigne 61 w -= ew; 62 } 63 if (render && overflow) 64 - drw_text(drw, ellipsis_x, y, ellipsis_w, h, 0, "...", invert); 65 + drw_text(drw, ellipsis_x, y, ellipsis_w, h, 0, "...", invert,statusfontindex); 66 67 if (!*text || overflow) { 68 break; 69 @@ -395,19 +397,19 @@ drw_map(Drw *drw, Window win, int x, int 70 } 71 72 unsigned int 73 -drw_fontset_getwidth(Drw *drw, const char *text) 74 +drw_fontset_getwidth(Drw *drw, const char *text,int statusfontindex) 75 { 76 if (!drw || !drw->fonts || !text) 77 return 0; 78 - return drw_text(drw, 0, 0, 0, 0, 0, text, 0); 79 + return drw_text(drw, 0, 0, 0, 0, 0, text, 0,statusfontindex); 80 } 81 82 unsigned int 83 -drw_fontset_getwidth_clamp(Drw *drw, const char *text, unsigned int n) 84 +drw_fontset_getwidth_clamp(Drw *drw, const char *text, unsigned int n, int statusfontindex) 85 { 86 unsigned int tmp = 0; 87 if (drw && drw->fonts && text && n) 88 - tmp = drw_text(drw, 0, 0, 0, 0, 0, text, n); 89 + tmp = drw_text(drw, 0, 0, 0, 0, 0, text, n,statusfontindex); 90 return MIN(n, tmp); 91 } 92 93 diff -up /dwm-6.4/drw.h ./drw.h 94 --- /dwm-6.4/drw.h 2022-10-04 19:38:18.000000000 +0200 95 +++ ./drw.h 2023-12-18 11:18:22.625584159 +0100 96 @@ -34,8 +34,8 @@ void drw_free(Drw *drw); 97 /* Fnt abstraction */ 98 Fnt *drw_fontset_create(Drw* drw, const char *fonts[], size_t fontcount); 99 void drw_fontset_free(Fnt* set); 100 -unsigned int drw_fontset_getwidth(Drw *drw, const char *text); 101 -unsigned int drw_fontset_getwidth_clamp(Drw *drw, const char *text, unsigned int n); 102 +unsigned int drw_fontset_getwidth(Drw *drw, const char *text,int statusfontindex); 103 +unsigned int drw_fontset_getwidth_clamp(Drw *drw, const char *text, unsigned int n, int statusfontindex); 104 void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h); 105 106 /* Colorscheme abstraction */ 107 @@ -52,7 +52,7 @@ void drw_setscheme(Drw *drw, Clr *scm); 108 109 /* Drawing functions */ 110 void drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert); 111 -int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert); 112 +int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert, int statusfontindex ); 113 114 /* Map functions */ 115 void drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h); 116 Only in .: drw.o 117 Only in .: dwm 118 diff -up /dwm-6.4/dwm.c ./dwm.c 119 --- /dwm-6.4/dwm.c 2022-10-04 19:38:18.000000000 +0200 120 +++ ./dwm.c 2023-12-18 11:25:53.718924073 +0100 121 @@ -55,8 +55,7 @@ 122 #define WIDTH(X) ((X)->w + 2 * (X)->bw) 123 #define HEIGHT(X) ((X)->h + 2 * (X)->bw) 124 #define TAGMASK ((1 << LENGTH(tags)) - 1) 125 -#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad) 126 - 127 +#define TEXTW(X,F) (drw_fontset_getwidth(drw, (X),(F)) + lrpad) 128 /* enums */ 129 enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ 130 enum { SchemeNorm, SchemeSel }; /* color schemes */ 131 @@ -435,14 +434,14 @@ buttonpress(XEvent *e) 132 if (ev->window == selmon->barwin) { 133 i = x = 0; 134 do 135 - x += TEXTW(tags[i]); 136 + x += TEXTW(tags[i],0); 137 while (ev->x >= x && ++i < LENGTH(tags)); 138 if (i < LENGTH(tags)) { 139 click = ClkTagBar; 140 arg.ui = 1 << i; 141 - } else if (ev->x < x + TEXTW(selmon->ltsymbol)) 142 + } else if (ev->x < x + TEXTW(selmon->ltsymbol,0)) 143 click = ClkLtSymbol; 144 - else if (ev->x > selmon->ww - (int)TEXTW(stext)) 145 + else if (ev->x > selmon->ww - (int)TEXTW(stext,0)) 146 click = ClkStatusText; 147 else 148 click = ClkWinTitle; 149 @@ -711,8 +710,8 @@ drawbar(Monitor *m) 150 /* draw status first so it can be overdrawn by tags later */ 151 if (m == selmon) { /* status is only drawn on selected monitor */ 152 drw_setscheme(drw, scheme[SchemeNorm]); 153 - tw = TEXTW(stext) - lrpad + 2; /* 2px right padding */ 154 - drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0); 155 + tw = TEXTW(stext,statusfontindex) - lrpad + 2; /* 2px right padding */ 156 + drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0,statusfontindex); 157 } 158 159 for (c = m->clients; c; c = c->next) { 160 @@ -722,23 +721,23 @@ drawbar(Monitor *m) 161 } 162 x = 0; 163 for (i = 0; i < LENGTH(tags); i++) { 164 - w = TEXTW(tags[i]); 165 + w = TEXTW(tags[i],0); 166 drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]); 167 - drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i); 168 + drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i,0); 169 if (occ & 1 << i) 170 drw_rect(drw, x + boxs, boxs, boxw, boxw, 171 m == selmon && selmon->sel && selmon->sel->tags & 1 << i, 172 urg & 1 << i); 173 x += w; 174 } 175 - w = TEXTW(m->ltsymbol); 176 + w = TEXTW(m->ltsymbol,0); 177 drw_setscheme(drw, scheme[SchemeNorm]); 178 - x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0); 179 + x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0,0); 180 181 if ((w = m->ww - tw - x) > bh) { 182 if (m->sel) { 183 drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]); 184 - drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0); 185 + drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0,0); 186 if (m->sel->isfloating) 187 drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0); 188 } else { 189 Only in .: dwm.o 190 Only in .: dwm-statusbarfont-6.4.diff 191 Only in .: util.o