diff options
-rw-r--r-- | config.def.h | 39 | ||||
-rw-r--r-- | dwl.c | 70 | ||||
-rw-r--r-- | patches/applied/dwm-rainbowtags-6.2.diff | 59 | ||||
-rw-r--r-- | patches/applied/gaplessgrid.patch | 89 |
4 files changed, 243 insertions, 14 deletions
diff --git a/config.def.h b/config.def.h index 74ce003..d69d0ff 100644 --- a/config.def.h +++ b/config.def.h @@ -20,14 +20,12 @@ static const int showbar = 0; /* 0 means no bar */ static const int topbar = 1; /* 0 means bottom bar */ static const char *fonts[] = { "BigBlueTermPlus Nerd Font:size=14" }; static const float rootcolor[] = COLOR(0x000000ff); -static const int trayspacing = 4; /* Spacing between icons in system tray */ -static const int traymargins = 4; /* System tray inner margins */ /* This conforms to the xdg-protocol. Set the alpha to zero to restore the old behavior */ static const float fullscreen_bg[] = {0.1f, 0.1f, 0.1f, 1.0f}; /* You can also use glsl colors */ static uint32_t colors[][3] = { /* fg bg border */ - [SchemeNorm] = { 0xbbbbbbff, 0x222222ff, 0x444444ff }, - [SchemeSel] = { 0xeeeeeeff, 0x005577ff, 0x005577ff }, + [SchemeNorm] = { 0xebdbb2ff, 0x1d2021ff, 0x32302fff }, + [SchemeSel] = { 0xebdbb2ff, 0x9d0006ff, 0x9d0006ff }, [SchemeUrg] = { 0, 0, 0x770000ff }, }; @@ -44,11 +42,36 @@ static char *tags[] = { " " }; -static const unsigned int ulinepad = 5; /* horizontal padding between the underline and tag */ +static const unsigned int ulinepad = 6; /* horizontal padding between the underline and tag */ static const unsigned int ulinestroke = 2; /* thickness / height of the underline */ static const unsigned int ulinevoffset = 0; /* how far above the bottom of the bar the line should appear */ static const int ulineall = 0; /* 1 to show underline on all tags, 0 for just the active ones */ +static uint32_t tagsel[][3] = { + /* fg bg */ + // gruvbox light + // { "#9d0006", "#1d2021", "" }, // red + // { "#79740e", "#1d2021", "" }, // green + // { "#b57614", "#1d2021", "" }, // yellow + // { "#076678", "#1d2021", "" }, // blue + // { "#8f3f71", "#1d2021", "" }, // magenta + // { "#427b58", "#1d2021", "" }, // cyan + // { "#af3a03", "#1d2021", "" }, // orange + // { "#928374", "#1d2021", "" }, // gray + // { "#ebdbb2", "#1d2021", "" }, // white + // gruvbox dark + { 0xcc241dff, 0x1d2021ff }, // red + { 0xd65d0eff, 0x1d2021ff }, // orange + { 0xd79921ff, 0x1d2021ff }, // yellow + { 0x458588ff, 0x1d2021ff }, // blue + { 0x8ec07cff, 0x1d2021ff }, // cyan + { 0x98971aff, 0x1d2021ff }, // green + { 0xb16286ff, 0x1d2021ff }, // magenta + { 0xfe8019ff, 0x1d2021ff }, // re orange + { 0xebdbb2ff, 0x1d2021ff }, // white + { 0x7c6f64ff, 0x1d2021ff }, // empty +}; + /* logging */ static int log_level = WLR_ERROR; @@ -80,6 +103,7 @@ const char *spnews[] = {"n", "alacritty", "--title", "spnews", "-e", "nb", NULL static const Layout layouts[] = { /* symbol arrange function */ { "[]=", tile }, + { "###", gaplessgrid }, { "[M]", monocle }, { "><>", NULL }, /* no layout function means floating behavior */ }; @@ -221,8 +245,9 @@ static const Key keys[] = { { META, XKB_KEY_Escape, view, {0} }, { MODKEY, XKB_KEY_q, killclient, {0} }, { MODKEY, XKB_KEY_s, setlayout, {.v = &layouts[0]} }, - { MODKEY, XKB_KEY_m, setlayout, {.v = &layouts[1]} }, - { MODKEY, XKB_KEY_n, setlayout, {.v = &layouts[2]} }, + { MODKEY, XKB_KEY_v, setlayout, {.v = &layouts[1]} }, + { MODKEY, XKB_KEY_m, setlayout, {.v = &layouts[2]} }, + { MODKEY, XKB_KEY_n, setlayout, {.v = &layouts[3]} }, { MODKEY|SHIFT, XKB_KEY_space, setlayout, {0} }, { MODKEY, XKB_KEY_space, togglefloating, {0} }, { MODKEY, XKB_KEY_f, togglefullscreen, {0} }, @@ -341,6 +341,7 @@ static void focusstack(const Arg *arg); static Client *focustop(Monitor *m); static void fullscreennotify(struct wl_listener *listener, void *data); static void gpureset(struct wl_listener *listener, void *data); +static void gaplessgrid(Monitor *m); static void handlesig(int signo); static void incnmaster(const Arg *arg); static void incigaps(const Arg *arg); @@ -1629,8 +1630,6 @@ void drawbar(Monitor *m) { int x, w, tw = 0; - int boxs = m->drw->font->height / 9; - int boxw = m->drw->font->height / 6 + 2; uint32_t i, occ = 0, urg = 0; Client *c; Buffer *buf; @@ -1661,14 +1660,18 @@ drawbar(Monitor *m) c = focustop(m); for (i = 0; i < LENGTH(tags); i++) { w = TEXTW(m, tags[i]); - drwl_setscheme(m->drw, colors[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]); + if (occ & 1 << i) + drwl_setscheme(m->drw, tagsel[i]); + else + drwl_setscheme(m->drw, tagsel[9]); + // drwl_setscheme(m->drw, (m->tagset[m->seltags] & 1 << i ? tagsel[i] : colors[SchemeNorm])); drwl_text(m->drw, x, 0, w, m->b.height, m->lrpad / 2, tags[i], urg & 1 << i); if (ulineall || m->tagset[m->seltags] & 1 << i) /* if there are conflicts, just move these lines directly underneath both 'drw_setscheme' and 'dr w_text' :) */ drwl_rect(m->drw, x + ulinepad, m->b.height - ulinestroke - ulinevoffset, w - (ulinepad * 2), ulinestroke, 1, 0); - if (occ & 1 << i) - drwl_rect(m->drw, x + boxs, boxs, boxw, boxw, - m == selmon && c && c->tags & 1 << i, - urg & 1 << i); + // if (occ & 1 << i) + // drwl_rect(m->drw, x + boxs, boxs, boxw, boxw, + // m == selmon && c && c->tags & 1 << i, + // urg & 1 << i); x += w; } w = TEXTW(m, m->ltsymbol); @@ -1875,6 +1878,56 @@ handlesig(int signo) } } +void +gaplessgrid(Monitor *m) +{ + unsigned int n = 0, i = 0, ch, cw, cn, rn, rows, cols; + Client *c; + + wl_list_for_each(c, &clients, link) + if (VISIBLEON(c, m) && !c->isfloating) + n++; + if (n == 0) + return; + + /* grid dimensions */ + for (cols = 0; cols <= (n / 2); cols++) + if ((cols * cols) >= n) + break; + + if (n == 5) /* set layout against the general calculation: not 1:2:2, but 2:3 */ + cols = 2; + + /* widescreen is better if 3 columns */ + if (n >= 3 && n <= 6 && (m->w.width / m->w.height) > 1) + cols = 3; + + rows = n / cols; + + /* window geometries */ + cw = cols ? m->w.width / cols : (unsigned int)m->w.width; + cn = 0; /* current column number */ + rn = 0; /* current row number */ + wl_list_for_each(c, &clients, link) { + unsigned int cx, cy; + if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen) + continue; + + if ((i / rows + 1) > (cols - n % cols)) + rows = n / cols + 1; + ch = rows ? m->w.height / rows : (unsigned int)m->w.height; + cx = m->w.x + cn * cw; + cy = m->w.y + rn * ch; + resize(c, (struct wlr_box) { cx, cy, cw, ch}, 0); + rn++; + if (rn >= rows) { + rn = 0; + cn++; + } + i++; + } +} + pid_t getparentprocess(pid_t p) { @@ -2897,6 +2950,9 @@ setup(void) drag_icon = wlr_scene_tree_create(&scene->tree); wlr_scene_node_place_below(&drag_icon->node, &layers[LyrBlock]->node); + if (LENGTH(tags) > LENGTH(tagsel)) + die("too few color schemes for the tags"); + /* Autocreates a renderer, either Pixman, GLES2 or Vulkan for us. The user * can also specify a renderer using the WLR_RENDERER env var. * The renderer is responsible for defining the various pixel formats it diff --git a/patches/applied/dwm-rainbowtags-6.2.diff b/patches/applied/dwm-rainbowtags-6.2.diff new file mode 100644 index 0000000..6c31062 --- /dev/null +++ b/patches/applied/dwm-rainbowtags-6.2.diff @@ -0,0 +1,59 @@ +diff --git a/config.def.h b/config.def.h +index 1c0b587..3fb5cf8 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -21,6 +21,18 @@ static const char *colors[][3] = { + /* tagging */ + static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; + ++static const char *tagsel[][2] = { ++ { "#ffffff", "#ff0000" }, ++ { "#ffffff", "#ff7f00" }, ++ { "#000000", "#ffff00" }, ++ { "#000000", "#00ff00" }, ++ { "#ffffff", "#0000ff" }, ++ { "#ffffff", "#4b0082" }, ++ { "#ffffff", "#9400d3" }, ++ { "#000000", "#ffffff" }, ++ { "#ffffff", "#000000" }, ++}; ++ + static const Rule rules[] = { + /* xprop(1): + * WM_CLASS(STRING) = instance, class +diff --git a/dwm.c b/dwm.c +index b0b3466..c16d5f5 100644 +--- a/dwm.c ++++ b/dwm.c +@@ -264,6 +264,7 @@ static Atom wmatom[WMLast], netatom[NetLast]; + static int running = 1; + static Cur *cursor[CurLast]; + static Clr **scheme; ++static Clr **tagscheme; + static Display *dpy; + static Drw *drw; + static Monitor *mons, *selmon; +@@ -717,7 +718,7 @@ drawbar(Monitor *m) + x = 0; + for (i = 0; i < LENGTH(tags); i++) { + w = TEXTW(tags[i]); +- drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]); ++ drw_setscheme(drw, (m->tagset[m->seltags] & 1 << i ? tagscheme[i] : scheme[SchemeNorm])); + drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i); + if (occ & 1 << i) + drw_rect(drw, x + boxs, boxs, boxw, boxw, +@@ -1568,9 +1569,14 @@ setup(void) + cursor[CurResize] = drw_cur_create(drw, XC_sizing); + cursor[CurMove] = drw_cur_create(drw, XC_fleur); + /* init appearance */ ++ if (LENGTH(tags) > LENGTH(tagsel)) ++ die("too few color schemes for the tags"); + scheme = ecalloc(LENGTH(colors), sizeof(Clr *)); + for (i = 0; i < LENGTH(colors); i++) + scheme[i] = drw_scm_create(drw, colors[i], 3); ++ tagscheme = ecalloc(LENGTH(tagsel), sizeof(Clr *)); ++ for (i = 0; i < LENGTH(tagsel); i++) ++ tagscheme[i] = drw_scm_create(drw, tagsel[i], 2); + /* init bars */ + updatebars(); + updatestatus(); diff --git a/patches/applied/gaplessgrid.patch b/patches/applied/gaplessgrid.patch new file mode 100644 index 0000000..2af1072 --- /dev/null +++ b/patches/applied/gaplessgrid.patch @@ -0,0 +1,89 @@ +diff --git a/config.def.h b/config.def.h +index 22d2171..014a909 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -34,6 +34,7 @@ static const Layout layouts[] = { + { "[]=", tile }, + { "><>", NULL }, /* no layout function means floating behavior */ + { "[M]", monocle }, ++ { "###", gaplessgrid }, + }; + + /* monitors */ +@@ -139,6 +140,7 @@ static const Key keys[] = { + { MODKEY, XKB_KEY_t, setlayout, {.v = &layouts[0]} }, + { MODKEY, XKB_KEY_f, setlayout, {.v = &layouts[1]} }, + { MODKEY, XKB_KEY_m, setlayout, {.v = &layouts[2]} }, ++ { MODKEY, XKB_KEY_g, setlayout, {.v = &layouts[3]} }, + { MODKEY, XKB_KEY_space, setlayout, {0} }, + { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} }, + { MODKEY, XKB_KEY_e, togglefullscreen, {0} }, +diff --git a/dwl.c b/dwl.c +index dc0c861..875d8cd 100644 +--- a/dwl.c ++++ b/dwl.c +@@ -292,6 +292,7 @@ static void focusstack(const Arg *arg); + static Client *focustop(Monitor *m); + static void fullscreennotify(struct wl_listener *listener, void *data); + static void gpureset(struct wl_listener *listener, void *data); ++static void gaplessgrid(Monitor *m); + static void handlesig(int signo); + static void incnmaster(const Arg *arg); + static void inputdevice(struct wl_listener *listener, void *data); +@@ -1510,6 +1511,56 @@ handlesig(int signo) + } + } + ++void ++gaplessgrid(Monitor *m) ++{ ++ unsigned int n = 0, i = 0, ch, cw, cn, rn, rows, cols; ++ Client *c; ++ ++ wl_list_for_each(c, &clients, link) ++ if (VISIBLEON(c, m) && !c->isfloating) ++ n++; ++ if (n == 0) ++ return; ++ ++ /* grid dimensions */ ++ for (cols = 0; cols <= (n / 2); cols++) ++ if ((cols * cols) >= n) ++ break; ++ ++ if (n == 5) /* set layout against the general calculation: not 1:2:2, but 2:3 */ ++ cols = 2; ++ ++ /* widescreen is better if 3 columns */ ++ if (n >= 3 && n <= 6 && (m->w.width / m->w.height) > 1) ++ cols = 3; ++ ++ rows = n / cols; ++ ++ /* window geometries */ ++ cw = cols ? m->w.width / cols : m->w.width; ++ cn = 0; /* current column number */ ++ rn = 0; /* current row number */ ++ wl_list_for_each(c, &clients, link) { ++ unsigned int cx, cy; ++ if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen) ++ continue; ++ ++ if ((i / rows + 1) > (cols - n % cols)) ++ rows = n / cols + 1; ++ ch = rows ? m->w.height / rows : m->w.height; ++ cx = m->w.x + cn * cw; ++ cy = m->w.y + rn * ch; ++ resize(c, (struct wlr_box) { cx, cy, cw, ch}, 0); ++ rn++; ++ if (rn >= rows) { ++ rn = 0; ++ cn++; ++ } ++ i++; ++ } ++} ++ + void + incnmaster(const Arg *arg) + { |