sites

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 44968658e41149b13d4d0df11a306ee76259a697
parent 0a82280cd666a63888038295c72aedbc50559c02
Author: Andrew Milkovich <amilkovich@gmail.com>
Date:   Wed, 26 Jun 2013 22:46:48 -0700

updated and simplified dualstatus patch. implementation now using drw.

Diffstat:
Mdwm.suckless.org/patches/dualstatus.md | 7++++---
Mdwm.suckless.org/patches/dwm-6.1-dualstatus.diff | 211+++++++++++++++++++++++++++++++++----------------------------------------------
2 files changed, 91 insertions(+), 127 deletions(-)

diff --git a/dwm.suckless.org/patches/dualstatus.md b/dwm.suckless.org/patches/dualstatus.md @@ -3,20 +3,21 @@ dualstatus Description ----------- -This patch will enable both a top and bottom status bar in dwm. The bottom bar can be toggled along with the top bar or independently. +This patch will enable an extra status bar in dwm. The extra bar can be toggled along with the standard bar or independently. The status bar text can be set as follows: -xsetroot -name "Top textBOTTOM=Bottom text" +xsetroot -name "Top text;Bottom text" Download -------- - * [dwm-6.1-dualstatus.diff](dwm-6.1-dualstatus.diff) (5793b) (20130123) + * [dwm-6.1-dualstatus.diff](dwm-6.1-dualstatus.diff) (4655b) (20130626) Screenshot ---------- a simple dual status bar + ![alt text](dwm-dualstatus.png) Authors diff --git a/dwm.suckless.org/patches/dwm-6.1-dualstatus.diff b/dwm.suckless.org/patches/dwm-6.1-dualstatus.diff @@ -1,12 +1,12 @@ diff --git a/config.def.h b/config.def.h -index 8fd5d4a..6daa608 100644 +index d300687..e286e5d 100644 --- a/config.def.h +++ b/config.def.h @@ -12,6 +12,7 @@ static const unsigned int borderpx = 1; /* border pixel of windows */ static const unsigned int snap = 32; /* snap pixel */ static const Bool showbar = True; /* False means no bar */ static const Bool topbar = True; /* False means bottom bar */ -+static const Bool bottombar = True; /* True means an extra bar at the bottom */ ++static const Bool extrabar = True; /* False means no extra bar */ /* tagging */ static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; @@ -14,178 +14,141 @@ index 8fd5d4a..6daa608 100644 { MODKEY, XK_p, spawn, {.v = dmenucmd } }, { MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } }, { MODKEY, XK_b, togglebar, {0} }, -+ { MODKEY, XK_b, togglebottombar,{0} }, ++ { MODKEY, XK_b, toggleextrabar, {0} }, { MODKEY, XK_j, focusstack, {.i = +1 } }, { MODKEY, XK_k, focusstack, {.i = -1 } }, { MODKEY, XK_i, incnmaster, {.i = +1 } }, diff --git a/dwm.c b/dwm.c -index d9443da..0d358ca 100644 +index 314adf4..0ab7edc 100644 --- a/dwm.c +++ b/dwm.c -@@ -131,6 +131,7 @@ struct Monitor { - int nmaster; - int num; - int by; /* bar geometry */ -+ int bby; /* bottom bar geometry */ - int mx, my, mw, mh; /* screen size */ - int wx, wy, ww, wh; /* window area */ - unsigned int seltags; -@@ -138,11 +139,14 @@ struct Monitor { - unsigned int tagset[2]; - Bool showbar; - Bool topbar; -+ Bool showbottombar; -+ Bool bottombar; - Client *clients; - Client *sel; - Client *stack; - Monitor *next; - Window barwin; -+ Window bbarwin; - const Layout *lt[2]; - }; +@@ -140,6 +140,13 @@ typedef struct { + int monitor; + } Rule; -@@ -229,6 +233,7 @@ static void tagmon(const Arg *arg); - static int textnw(const char *text, unsigned int len); ++typedef struct { ++ int y; ++ Bool show; ++ Window win; ++ char text[256]; ++} Bar; ++ + /* function declarations */ + static void applyrules(Client *c); + static Bool applysizehints(Client *c, int *x, int *y, int *w, int *h, Bool interact); +@@ -209,6 +216,7 @@ static void tag(const Arg *arg); + static void tagmon(const Arg *arg); static void tile(Monitor *); static void togglebar(const Arg *arg); -+static void togglebottombar(const Arg *arg); ++static void toggleextrabar(const Arg *arg); static void togglefloating(const Arg *arg); static void toggletag(const Arg *arg); static void toggleview(const Arg *arg); -@@ -256,6 +261,7 @@ static void zoom(const Arg *arg); - /* variables */ - static const char broken[] = "broken"; - static char stext[256]; -+static char btext[256]; - static int screen; - static int sw, sh; /* X display screen geometry width, height */ - static int bh, blw = 0; /* bar geometry */ -@@ -515,6 +521,8 @@ cleanupmon(Monitor *mon) { - } - XUnmapWindow(dpy, mon->barwin); - XDestroyWindow(dpy, mon->barwin); -+ XUnmapWindow(dpy, mon->bbarwin); -+ XDestroyWindow(dpy, mon->bbarwin); - free(mon); - } +@@ -266,6 +274,7 @@ static Drw *drw; + static Fnt *fnt; + static Monitor *mons, *selmon; + static Window root; ++static Bar eb; -@@ -585,8 +593,10 @@ configurenotify(XEvent *e) { - XFreePixmap(dpy, dc.drawable); - dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen)); + /* configuration, allows nested code to access above variables */ + #include "config.h" +@@ -469,6 +478,8 @@ cleanup(void) { + while(m->stack) + unmanage(m->stack, False); + XUngrabKey(dpy, AnyKey, AnyModifier, root); ++ XUnmapWindow(dpy, eb.win); ++ XDestroyWindow(dpy, eb.win); + while(mons) + cleanupmon(mons); + drw_cur_free(drw, cursor[CurNormal]); +@@ -569,6 +580,7 @@ configurenotify(XEvent *e) { updatebars(); -- for(m = mons; m; m = m->next) -+ for(m = mons; m; m = m->next) { + for(m = mons; m; m = m->next) XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, m->ww, bh); -+ XMoveResizeWindow(dpy, m->bbarwin, m->wx, m->bby, m->ww, bh); -+ } ++ XMoveResizeWindow(dpy, eb.win, mons->wx, eb.y, mons->ww, bh); focus(NULL); arrange(NULL); } -@@ -657,6 +667,8 @@ createmon(void) { - m->nmaster = nmaster; - m->showbar = showbar; - m->topbar = topbar; -+ m->bottombar = bottombar; -+ m->showbottombar = bottombar ? True : False; - m->lt[0] = &layouts[0]; - m->lt[1] = &layouts[1 % LENGTH(layouts)]; - strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol); -@@ -755,6 +767,15 @@ drawbar(Monitor *m) { - drawtext(NULL, dc.norm, False); +@@ -739,6 +751,9 @@ drawbar(Monitor *m) { + } } - XCopyArea(dpy, dc.drawable, m->barwin, dc.gc, 0, 0, m->ww, bh, 0, 0); -+ if(m->showbottombar) { -+ dc.x = 0; -+ dc.w = TEXTW(btext); -+ drawtext(btext, dc.norm, False); -+ dc.x += dc.w; -+ dc.w = m->ww - dc.x; -+ drawtext(NULL, dc.norm, False); -+ XCopyArea(dpy, dc.drawable, m->bbarwin, dc.gc, 0, 0, m->ww, bh, 0, 0); -+ } - XSync(dpy, False); + drw_map(drw, m->barwin, 0, 0, m->ww, bh); ++ drw_setscheme(drw, &scheme[SchemeNorm]); ++ drw_text(drw, 0, 0, mons->ww, bh, eb.text, 0); ++ drw_map(drw, eb.win, 0, 0, mons->ww, bh); } -@@ -1745,6 +1766,14 @@ togglebar(const Arg *arg) { + void +@@ -1503,6 +1518,7 @@ setup(void) { + bh = fnt->h + 2; + drw = drw_create(dpy, screen, root, sw, sh); + drw_setfont(drw, fnt); ++ eb.show = extrabar; + updategeom(); + /* init atoms */ + wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False); +@@ -1631,6 +1647,16 @@ togglebar(const Arg *arg) { } void -+togglebottombar(const Arg *arg) { -+ selmon->showbottombar = !selmon->showbottombar; -+ updatebarpos(selmon); -+ XMoveResizeWindow(dpy, selmon->bbarwin, selmon->wx, selmon->bby, selmon->ww, bh); -+ arrange(selmon); ++toggleextrabar(const Arg *arg) { ++ if(selmon == mons) { ++ eb.show = !eb.show; ++ updatebarpos(selmon); ++ XMoveResizeWindow(dpy, eb.win, selmon->wx, eb.y, selmon->ww, bh); ++ arrange(selmon); ++ } +} + +void togglefloating(const Arg *arg) { if(!selmon->sel) return; -@@ -1848,6 +1877,13 @@ updatebars(void) { - CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa); - XDefineCursor(dpy, m->barwin, cursor[CurNormal]); +@@ -1735,6 +1761,13 @@ updatebars(void) { + XDefineCursor(dpy, m->barwin, cursor[CurNormal]->cursor); XMapRaised(dpy, m->barwin); -+ if (m->bottombar) { -+ m->bbarwin = XCreateWindow(dpy, root, m->wx, m->bby, m->ww, bh, 0, DefaultDepth(dpy, screen), -+ CopyFromParent, DefaultVisual(dpy, screen), -+ CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa); -+ XDefineCursor(dpy, m->bbarwin, cursor[CurNormal]); -+ XMapRaised(dpy, m->bbarwin); -+ } } ++ if(!eb.win) { ++ eb.win = XCreateWindow(dpy, root, mons->wx, eb.y, mons->ww, bh, 0, DefaultDepth(dpy, screen), ++ CopyFromParent, DefaultVisual(dpy, screen), ++ CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa); ++ XDefineCursor(dpy, eb.win, cursor[CurNormal]->cursor); ++ XMapRaised(dpy, eb.win); ++ } } -@@ -1862,6 +1898,12 @@ updatebarpos(Monitor *m) { + void +@@ -1748,6 +1781,13 @@ updatebarpos(Monitor *m) { } else m->by = -bh; -+ if (m->showbottombar) { ++ if(m == mons && eb.show) { + m->wh -= bh; -+ m->bby = m->wy + m->wh; ++ eb.y = topbar ? m->wy + m->wh : m->wy; ++ m->wy = m->topbar ? m->wy : m->wy + bh; + } + else -+ m->bby = -bh; ++ eb.y = -bh; } void -@@ -2034,8 +2076,39 @@ updatetitle(Client *c) { +@@ -1920,8 +1960,19 @@ updatetitle(Client *c) { void updatestatus(void) { - if(!gettextprop(root, XA_WM_NAME, stext, sizeof(stext))) -+ char buftext[512]; -+ if(!gettextprop(root, XA_WM_NAME, buftext, sizeof(buftext))) ++ char text[512]; ++ if(!gettextprop(root, XA_WM_NAME, text, sizeof(text))) { strcpy(stext, "dwm-"VERSION); ++ eb.text[0] = '\0'; ++ } + else { -+ char* blocation = strstr(buftext,"BOTTOM="); -+ if (blocation != NULL) { -+ int c = 0; -+ for (char* i = buftext; i < blocation; i++) { -+ if (c < sizeof(stext) - 1) -+ stext[c] = *i; -+ else -+ break; -+ c++; -+ } -+ stext[c] = '\0'; -+ blocation += 7; -+ c = 0; -+ for (char* i = blocation; i < (blocation + sizeof(buftext)); i++) -+ { -+ if (c < sizeof(btext) - 1) -+ btext[c] = *i; -+ else -+ break; -+ c++; -+ } -+ btext[c] = '\0'; -+ } -+ else { -+ for (int i = 0; i < sizeof(stext); i++) -+ stext[i] = buftext[i]; -+ stext[sizeof(stext) - 1] = '\0'; ++ char *e = strchr(text, ';'); ++ if(e) { ++ *e = '\0'; e++; ++ strncpy(eb.text, e, sizeof(eb.text)); + } ++ strncpy(stext, text, sizeof(stext)); + } drawbar(selmon); }