Adding staticstatus patch

This commit is contained in:
bakkeby 2020-06-10 11:52:35 +02:00
parent 622c4bc0d6
commit 164095db40
4 changed files with 52 additions and 14 deletions

View File

@ -15,6 +15,8 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
### Changelog:
2020-06-10 - Added the staticstatus patch
2020-05-31 - Added the keymodes patch
2020-05-29 - Added the color emoji patch
@ -359,6 +361,9 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
- [stacker](https://dwm.suckless.org/patches/stacker/)
- provides comprehensive utilities for managing the client stack
- [staticstatus](https://dwm.suckless.org/patches/staticstatus/)
- allows the status text to be fixed to the bar on a specific monitor rather than being drawn on the focused monitor
- [statuscmd](https://dwm.suckless.org/patches/statuscmd/)
- adds the ability to execute shell commands based on the mouse button and position when clicking the status bar

View File

@ -32,6 +32,9 @@ static const int focusonwheel = 0;
static const int horizpadbar = 2; /* horizontal padding for statusbar */
static const int vertpadbar = 0; /* vertical padding for statusbar */
#endif // STATUSPADDING_PATCH
#if STATICSTATUS_PATCH && !STATUSALLMONS_PATCH
static const int statmonval = 0;
#endif // STATICSTATUS_PATCH
#if SYSTRAY_PATCH
static const unsigned int systraypinning = 0; /* 0: sloppy systray follows selected monitor, >0: pin systray to monitor X */
static const unsigned int systrayspacing = 2; /* systray spacing */

51
dwm.c
View File

@ -248,6 +248,7 @@ struct Monitor {
int nmaster;
int num;
int by; /* bar geometry */
int tw; /* bar text width */
#if EXTRABAR_PATCH
int eby; /* extra bar geometry */
#endif // EXTRABAR_PATCH
@ -458,7 +459,6 @@ static char estext[256];
static int screen;
static int sw, sh; /* X display screen geometry width, height */
static int bh, blw = 0; /* bar geometry */
static int tw = 0; /* bar text width */
static int lrpad; /* sum of left and right padding for text */
#if BARPADDING_PATCH
static int vp; /* vertical padding for bar */
@ -506,6 +506,9 @@ static Clr **scheme;
static Display *dpy;
static Drw *drw;
static Monitor *mons, *selmon;
#if STATICSTATUS_PATCH && !STATUSALLMONS_PATCH
static Monitor *statmon;
#endif // STATICSTATUS_PATCH
static Window root, wmcheckwin;
/* configuration, allows nested code to access above variables */
@ -820,13 +823,13 @@ buttonpress(XEvent *e)
} else if (ev->x < x + blw)
click = ClkLtSymbol;
#endif // TAGGRID_PATCH
else if (ev->x > selmon->ww - tw + padding)
else if (ev->x > selmon->ww - selmon->tw + padding)
#if !STATUSCMD_PATCH
click = ClkStatusText;
#else
{
click = ClkStatusText;
xc = selmon->ww - tw + padding;
xc = selmon->ww - selmon->tw + padding;
#if STATUSPADDING_PATCH
xc += lrpad / 2;
#endif // STATUSPADDING_PATCH
@ -1446,7 +1449,12 @@ drawbar(Monitor *m)
/* draw status first so it can be overdrawn by tags later */
#if !STATUSALLMONS_PATCH
if (m == selmon) { /* status is only drawn on selected monitor */
#if STATICSTATUS_PATCH
if (m == statmon)
#else
if (m == selmon)
#endif // STATICSTATUS_PATCH
{ /* status is only drawn on selected monitor */
#endif // STATUSALLMONS_PATCH
#if VTCOLORS_PATCH
drw_setscheme(drw, scheme[SchemeStatus]);
@ -1455,9 +1463,9 @@ drawbar(Monitor *m)
#endif // VTCOLORS_PATCH
#if STATUSCOLORS_PATCH
#if STATUSPADDING_PATCH
tw = textw_wosc(stext) + lrpad + 2;
m->tw = textw_wosc(stext) + lrpad + 2;
#else
tw = textw_wosc(stext) + 2;
m->tw = textw_wosc(stext) + 2;
#endif // STATUSPADDING_PATCH
while (1) {
if ((unsigned int)*ts > LENGTH(colors)) {
@ -1466,7 +1474,7 @@ drawbar(Monitor *m)
}
ctmp = *ts;
*ts = '\0';
drw_text(drw, m->ww - tw - stw + tx, 0, tw - tx, bh, stp, tp, 0);
drw_text(drw, m->ww - m->tw - stw + tx, 0, m->tw - tx, bh, stp, tp, 0);
tx += TEXTW(tp) - lrpad;
if (ctmp == '\0')
break;
@ -1475,14 +1483,14 @@ drawbar(Monitor *m)
tp = ++ts;
}
#elif STATUS2D_PATCH
tw = m->ww - drawstatusbar(m, bh, stext, stw, stp);
m->tw = m->ww - drawstatusbar(m, bh, stext, stw, stp);
#else // STATUSCOLORS_PATCH
#if STATUSPADDING_PATCH
tw = TEXTW(stext);
m->tw = TEXTW(stext);
#else
tw = TEXTW(stext) - lrpad + 2; /* 2px right padding */
m->tw = TEXTW(stext) - lrpad + 2; /* 2px right padding */
#endif // STATUSPADDING_PATCH
drw_text(drw, m->ww - tw - stw, 0, tw, bh, stp, stext, 0);
drw_text(drw, m->ww - m->tw - stw, 0, m->tw, bh, stp, stext, 0);
#endif // STATUSCOLORS_PATCH
#if !STATUSALLMONS_PATCH
}
@ -1578,7 +1586,7 @@ drawbar(Monitor *m)
x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0);
#endif // LEFTLAYOUT_PATCH
if ((w = m->ww - tw - stw - x) > bh)
if ((w = m->ww - m->tw - stw - x) > bh)
{
#if AWESOMEBAR_PATCH
if (n > 0) {
@ -3760,7 +3768,7 @@ updategeom(void)
else
mons = createmon();
}
for (i = 0, m = mons; i < nn && m; m = m->next, i++)
for (i = 0, m = mons; i < nn && m; m = m->next, i++) {
if (i >= n
|| unique[i].x_org != m->mx || unique[i].y_org != m->my
|| unique[i].width != m->mw || unique[i].height != m->mh)
@ -3773,6 +3781,11 @@ updategeom(void)
m->mh = m->wh = unique[i].height;
updatebarpos(m);
}
#if STATICSTATUS_PATCH && !STATUSALLMONS_PATCH
if (i == statmonval)
statmon = m;
#endif // STATICSTATUS_PATCH
}
} else { /* less monitors available nn < n */
for (i = nn; i < n; i++) {
for (m = mons; m && m->next; m = m->next);
@ -3786,6 +3799,10 @@ updategeom(void)
}
if (m == selmon)
selmon = mons;
#if STATICSTATUS_PATCH && !STATUSALLMONS_PATCH
if (m == statmon)
statmon = mons;
#endif // STATICSTATUS_PATCH
cleanupmon(m);
}
}
@ -3802,6 +3819,10 @@ updategeom(void)
updatebarpos(mons);
}
}
#if STATICSTATUS_PATCH && !STATUSALLMONS_PATCH
if (!statmon)
statmon = mons;
#endif // STATICSTATUS_PATCH
if (dirty) {
selmon = mons;
selmon = wintomon(root);
@ -3909,9 +3930,11 @@ updatestatus(void)
#if STATUSALLMONS_PATCH
for (m = mons; m; m = m->next)
drawbar(m);
#elif STATICSTATUS_PATCH
drawbar(statmon);
#else
drawbar(selmon);
#endif // STATUSALLMONS_PATCH
#endif // STATUSALLMONS_PATCH | STATICSTATUS_PATCH
#if SYSTRAY_PATCH
if (showsystray)
updatesystray();

View File

@ -509,6 +509,13 @@
*/
#define STACKER_PATCH 0
/* This patch allows the status text to be fixed to the bar on a specific
* monitor rather than being drawn on the focused monitor.
* The statusallmons patch takes precedence over this patch.
* https://dwm.suckless.org/patches/staticstatus/
*/
#define STATICSTATUS_PATCH 0
/* Status2d allows colors and rectangle drawing in the dwm status bar.
* This patch is incompatible with the statuscolors patch which takes precedence.
* This patch is incompatible with the extrabar patch.