|
| 1 | +diff --git a/config.def.h b/config.def.h |
| 2 | +index 7054c06..b96107a 100644 |
| 3 | +--- a/config.def.h |
| 4 | ++++ b/config.def.h |
| 5 | +@@ -15,6 +15,7 @@ static const unsigned int borderpx = 1; /* border pixel of windows */ |
| 6 | + static const unsigned int snap = 32; /* snap pixel */ |
| 7 | + static const int showbar = 1; /* 0 means no bar */ |
| 8 | + static const int topbar = 1; /* 0 means bottom bar */ |
| 9 | ++static const int extrabar = 1; /* 0 means no extra bar */ |
| 10 | + |
| 11 | + /* tagging */ |
| 12 | + static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; |
| 13 | +@@ -62,6 +63,7 @@ static Key keys[] = { |
| 14 | + { MODKEY, XK_p, spawn, {.v = dmenucmd } }, |
| 15 | + { MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } }, |
| 16 | + { MODKEY, XK_b, togglebar, {0} }, |
| 17 | ++ { MODKEY, XK_b, toggleextrabar, {0} }, |
| 18 | + { MODKEY, XK_j, focusstack, {.i = +1 } }, |
| 19 | + { MODKEY, XK_k, focusstack, {.i = -1 } }, |
| 20 | + { MODKEY, XK_i, incnmaster, {.i = +1 } }, |
| 21 | +diff --git a/dwm.c b/dwm.c |
| 22 | +index 0362114..9b7cd74 100644 |
| 23 | +--- a/dwm.c |
| 24 | ++++ b/dwm.c |
| 25 | +@@ -141,6 +141,13 @@ typedef struct { |
| 26 | + int monitor; |
| 27 | + } Rule; |
| 28 | + |
| 29 | ++typedef struct { |
| 30 | ++ int y; |
| 31 | ++ int show; |
| 32 | ++ Window win; |
| 33 | ++ char text[256]; |
| 34 | ++} Bar; |
| 35 | ++ |
| 36 | + /* function declarations */ |
| 37 | + static void applyrules(Client *c); |
| 38 | + static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact); |
| 39 | +@@ -210,6 +217,7 @@ static void tag(const Arg *arg); |
| 40 | + static void tagmon(const Arg *arg); |
| 41 | + static void tile(Monitor *); |
| 42 | + static void togglebar(const Arg *arg); |
| 43 | ++static void toggleextrabar(const Arg *arg); |
| 44 | + static void togglefloating(const Arg *arg); |
| 45 | + static void toggletag(const Arg *arg); |
| 46 | + static void toggleview(const Arg *arg); |
| 47 | +@@ -266,6 +274,7 @@ static Display *dpy; |
| 48 | + static Drw *drw; |
| 49 | + static Monitor *mons, *selmon; |
| 50 | + static Window root; |
| 51 | ++static Bar eb; |
| 52 | + |
| 53 | + /* configuration, allows nested code to access above variables */ |
| 54 | + #include "config.h" |
| 55 | +@@ -477,6 +486,8 @@ cleanup(void) |
| 56 | + while (m->stack) |
| 57 | + unmanage(m->stack, 0); |
| 58 | + XUngrabKey(dpy, AnyKey, AnyModifier, root); |
| 59 | ++ XUnmapWindow(dpy, eb.win); |
| 60 | ++ XDestroyWindow(dpy, eb.win); |
| 61 | + while (mons) |
| 62 | + cleanupmon(mons); |
| 63 | + for (i = 0; i < CurLast; i++) |
| 64 | +@@ -578,6 +589,7 @@ configurenotify(XEvent *e) |
| 65 | + updatebars(); |
| 66 | + for (m = mons; m; m = m->next) |
| 67 | + XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, m->ww, bh); |
| 68 | ++ XMoveResizeWindow(dpy, eb.win, mons->wx, eb.y, mons->ww, bh); |
| 69 | + focus(NULL); |
| 70 | + arrange(NULL); |
| 71 | + } |
| 72 | +@@ -751,6 +763,9 @@ drawbar(Monitor *m) |
| 73 | + } |
| 74 | + } |
| 75 | + drw_map(drw, m->barwin, 0, 0, m->ww, bh); |
| 76 | ++ drw_setscheme(drw, &scheme[SchemeNorm]); |
| 77 | ++ drw_text(drw, 0, 0, mons->ww, bh, eb.text, 0); |
| 78 | ++ drw_map(drw, eb.win, 0, 0, mons->ww, bh); |
| 79 | + } |
| 80 | + |
| 81 | + void |
| 82 | +@@ -1558,6 +1573,7 @@ setup(void) |
| 83 | + root = RootWindow(dpy, screen); |
| 84 | + drw = drw_create(dpy, screen, root, sw, sh); |
| 85 | + drw_load_fonts(drw, fonts, LENGTH(fonts)); |
| 86 | ++ eb.show = extrabar; |
| 87 | + if (!drw->fontcount) |
| 88 | + die("no fonts could be loaded.\n"); |
| 89 | + bh = drw->fonts[0]->h + 2; |
| 90 | +@@ -1699,6 +1715,17 @@ togglebar(const Arg *arg) |
| 91 | + } |
| 92 | + |
| 93 | + void |
| 94 | ++toggleextrabar(const Arg *arg) |
| 95 | ++{ |
| 96 | ++ if(selmon == mons) { |
| 97 | ++ eb.show = !eb.show; |
| 98 | ++ updatebarpos(selmon); |
| 99 | ++ XMoveResizeWindow(dpy, eb.win, selmon->wx, eb.y, selmon->ww, bh); |
| 100 | ++ arrange(selmon); |
| 101 | ++ } |
| 102 | ++} |
| 103 | ++ |
| 104 | ++void |
| 105 | + togglefloating(const Arg *arg) |
| 106 | + { |
| 107 | + if (!selmon->sel) |
| 108 | +@@ -1810,6 +1837,13 @@ updatebars(void) |
| 109 | + XDefineCursor(dpy, m->barwin, cursor[CurNormal]->cursor); |
| 110 | + XMapRaised(dpy, m->barwin); |
| 111 | + } |
| 112 | ++ if(!eb.win) { |
| 113 | ++ eb.win = XCreateWindow(dpy, root, mons->wx, eb.y, mons->ww, bh, 0, DefaultDepth(dpy, screen), |
| 114 | ++ CopyFromParent, DefaultVisual(dpy, screen), |
| 115 | ++ CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa); |
| 116 | ++ XDefineCursor(dpy, eb.win, cursor[CurNormal]->cursor); |
| 117 | ++ XMapRaised(dpy, eb.win); |
| 118 | ++ } |
| 119 | + } |
| 120 | + |
| 121 | + void |
| 122 | +@@ -1823,6 +1857,13 @@ updatebarpos(Monitor *m) |
| 123 | + m->wy = m->topbar ? m->wy + bh : m->wy; |
| 124 | + } else |
| 125 | + m->by = -bh; |
| 126 | ++ if(m == mons && eb.show) { |
| 127 | ++ m->wh -= bh; |
| 128 | ++ eb.y = topbar ? m->wy + m->wh : m->wy; |
| 129 | ++ m->wy = m->topbar ? m->wy : m->wy + bh; |
| 130 | ++ } |
| 131 | ++ else |
| 132 | ++ eb.y = -bh; |
| 133 | + } |
| 134 | + |
| 135 | + void |
| 136 | +@@ -1992,8 +2033,21 @@ updatetitle(Client *c) |
| 137 | + void |
| 138 | + updatestatus(void) |
| 139 | + { |
| 140 | +- if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext))) |
| 141 | ++ char text[1024]; |
| 142 | ++ if(!gettextprop(root, XA_WM_NAME, text, sizeof(text))) { |
| 143 | + strcpy(stext, "dwm-"VERSION); |
| 144 | ++ eb.text[0] = '\0'; |
| 145 | ++ } |
| 146 | ++ else { |
| 147 | ++ char *e = strchr(text, ';'); |
| 148 | ++ if(e) { |
| 149 | ++ *e = '\0'; e++; |
| 150 | ++ strncpy(eb.text, e, sizeof(eb.text)-1); |
| 151 | ++ } |
| 152 | ++ else |
| 153 | ++ eb.text[0] = '\0'; |
| 154 | ++ strncpy(stext, text, sizeof(stext)-1); |
| 155 | ++ } |
| 156 | + drawbar(selmon); |
| 157 | + } |
| 158 | + |
0 commit comments