dwm-staticstatus-20211010-a786211.diff (2445B)
1 diff --git a/config.def.h b/config.def.h 2 index a2ac963..e485712 100644 3 --- a/config.def.h 4 +++ b/config.def.h 5 @@ -18,6 +18,9 @@ static const char *colors[][3] = { 6 [SchemeSel] = { col_gray4, col_cyan, col_cyan }, 7 }; 8 9 +/* staticstatus */ 10 +static const int statmonval = 0; 11 + 12 /* tagging */ 13 static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; 14 15 diff --git a/dwm.c b/dwm.c 16 index 5e4d494..e5fa599 100644 17 --- a/dwm.c 18 +++ b/dwm.c 19 @@ -266,7 +266,7 @@ static Cur *cursor[CurLast]; 20 static Clr **scheme; 21 static Display *dpy; 22 static Drw *drw; 23 -static Monitor *mons, *selmon; 24 +static Monitor *mons, *selmon, *statmon; 25 static Window root, wmcheckwin; 26 27 /* configuration, allows nested code to access above variables */ 28 @@ -440,7 +440,7 @@ buttonpress(XEvent *e) 29 arg.ui = 1 << i; 30 } else if (ev->x < x + blw) 31 click = ClkLtSymbol; 32 - else if (ev->x > selmon->ww - (int)TEXTW(stext)) 33 + else if (m == statmon && ev->x > selmon->ww - (int)TEXTW(stext)) 34 click = ClkStatusText; 35 else 36 click = ClkWinTitle; 37 @@ -703,7 +703,7 @@ drawbar(Monitor *m) 38 Client *c; 39 40 /* draw status first so it can be overdrawn by tags later */ 41 - if (m == selmon) { /* status is only drawn on selected monitor */ 42 + if (m == statmon) { /* status is only drawn on user-defined status monitor */ 43 drw_setscheme(drw, scheme[SchemeNorm]); 44 tw = TEXTW(stext) - lrpad + 2; /* 2px right padding */ 45 drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0); 46 @@ -1879,7 +1879,7 @@ updategeom(void) 47 else 48 mons = createmon(); 49 } 50 - for (i = 0, m = mons; i < nn && m; m = m->next, i++) 51 + for (i = 0, m = mons; i < nn && m; m = m->next, i++){ 52 if (i >= n 53 || unique[i].x_org != m->mx || unique[i].y_org != m->my 54 || unique[i].width != m->mw || unique[i].height != m->mh) 55 @@ -1892,6 +1892,10 @@ updategeom(void) 56 m->mh = m->wh = unique[i].height; 57 updatebarpos(m); 58 } 59 + if(i == statmonval) 60 + statmon = m; 61 + } 62 + 63 } else { /* less monitors available nn < n */ 64 for (i = nn; i < n; i++) { 65 for (m = mons; m && m->next; m = m->next); 66 @@ -1905,6 +1909,8 @@ updategeom(void) 67 } 68 if (m == selmon) 69 selmon = mons; 70 + if (m == statmon) 71 + statmon = mons; 72 cleanupmon(m); 73 } 74 } 75 @@ -1992,7 +1998,7 @@ updatestatus(void) 76 { 77 if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext))) 78 strcpy(stext, "dwm-"VERSION); 79 - drawbar(selmon); 80 + drawbar(statmon); 81 } 82 83 void