commit 4c8e7b5d6ed1f1a7f3bb91ad757d21aca372effd
Author: Juan Ignacio Díaz <[email protected]>
Date:   Mon Apr 22 15:10:10 2024 -0300

    [dwm][patch][colorschemes] Add patch
    
    This patch allows you to define multiple colorschemes and cycle between
    them.

diff --git a/dwm.suckless.org/patches/colorschemes/dwm-colorschemes-6.5.diff 
b/dwm.suckless.org/patches/colorschemes/dwm-colorschemes-6.5.diff
new file mode 100644
index 00000000..7e7884ad
--- /dev/null
+++ b/dwm.suckless.org/patches/colorschemes/dwm-colorschemes-6.5.diff
@@ -0,0 +1,128 @@
+From 3f7b5b2ebdbd43f562229085802a16e1b1a4ee22 Mon Sep 17 00:00:00 2001
+From: Listeria monocytogenes <[email protected]>
+Date: Mon, 22 Apr 2024 14:28:01 -0300
+Subject: [PATCH] add setscheme() to cycle between colorschemes
+
+---
+ config.def.h | 15 +++++++++++----
+ dwm.c        | 33 ++++++++++++++++++++++++---------
+ 2 files changed, 35 insertions(+), 13 deletions(-)
+
+diff --git a/config.def.h b/config.def.h
+index 9efa774..f87f707 100644
+--- a/config.def.h
++++ b/config.def.h
+@@ -12,10 +12,16 @@ static const char col_gray2[]       = "#444444";
+ static const char col_gray3[]       = "#bbbbbb";
+ static const char col_gray4[]       = "#eeeeee";
+ static const char col_cyan[]        = "#005577";
+-static const char *colors[][3]      = {
+-      /*               fg         bg         border   */
+-      [SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
+-      [SchemeSel]  = { col_gray4, col_cyan,  col_cyan  },
++static const char *colors[][SchemeN][3] = {
++              /*               fg         bg         border   */
++      { /* dark */
++              [SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
++              [SchemeSel]  = { col_gray4, col_cyan,  col_cyan  },
++      },
++      { /* light */
++              [SchemeNorm] = { col_gray2, col_gray4, col_gray3 },
++              [SchemeSel]  = { col_gray1, col_cyan,  col_cyan  },
++      },
+ };
+ 
+ /* tagging */
+@@ -85,6 +91,7 @@ static const Key keys[] = {
+       { MODKEY,                       XK_period, focusmon,       {.i = +1 } },
+       { MODKEY|ShiftMask,             XK_comma,  tagmon,         {.i = -1 } },
+       { MODKEY|ShiftMask,             XK_period, tagmon,         {.i = +1 } },
++      { MODKEY,                       XK_s,      setscheme,      {.i = +1 } },
+       TAGKEYS(                        XK_1,                      0)
+       TAGKEYS(                        XK_2,                      1)
+       TAGKEYS(                        XK_3,                      2)
+diff --git a/dwm.c b/dwm.c
+index f1d86b2..53b1eaf 100644
+--- a/dwm.c
++++ b/dwm.c
+@@ -59,7 +59,7 @@
+ 
+ /* enums */
+ enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
+-enum { SchemeNorm, SchemeSel }; /* color schemes */
++enum { SchemeNorm, SchemeSel, SchemeN /* keeplast */ }; /* color schemes */
+ enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
+        NetWMFullscreen, NetActiveWindow, NetWMWindowType,
+        NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
+@@ -202,6 +202,7 @@ static void setfocus(Client *c);
+ static void setfullscreen(Client *c, int fullscreen);
+ static void setlayout(const Arg *arg);
+ static void setmfact(const Arg *arg);
++static void setscheme(const Arg *arg);
+ static void setup(void);
+ static void seturgent(Client *c, int urg);
+ static void showhide(Client *c);
+@@ -262,7 +263,7 @@ static void (*handler[LASTEvent]) (XEvent *) = {
+ static Atom wmatom[WMLast], netatom[NetLast];
+ static int running = 1;
+ static Cur *cursor[CurLast];
+-static Clr **scheme;
++static Clr **schemes, **scheme;
+ static Display *dpy;
+ static Drw *drw;
+ static Monitor *mons, *selmon;
+@@ -486,9 +487,9 @@ cleanup(void)
+               cleanupmon(mons);
+       for (i = 0; i < CurLast; i++)
+               drw_cur_free(drw, cursor[i]);
+-      for (i = 0; i < LENGTH(colors); i++)
+-              free(scheme[i]);
+-      free(scheme);
++      for (i = 0; i < LENGTH(colors) * SchemeN; i++)
++              free(schemes[i]);
++      free(schemes);
+       XDestroyWindow(dpy, wmcheckwin);
+       drw_free(drw);
+       XSync(dpy, False);
+@@ -1536,10 +1537,21 @@ setmfact(const Arg *arg)
+       arrange(selmon);
+ }
+ 
++void
++setscheme(const Arg *arg)
++{
++      scheme += arg->i * SchemeN;
++      if (scheme < schemes)
++              scheme = schemes + (LENGTH(colors) - 1) * SchemeN;
++      else if (scheme >= schemes + LENGTH(colors) * SchemeN)
++              scheme = schemes;
++      drawbars();
++}
++
+ void
+ setup(void)
+ {
+-      int i;
++      int i, j;
+       XSetWindowAttributes wa;
+       Atom utf8string;
+       struct sigaction sa;
+@@ -1584,9 +1596,12 @@ setup(void)
+       cursor[CurResize] = drw_cur_create(drw, XC_sizing);
+       cursor[CurMove] = drw_cur_create(drw, XC_fleur);
+       /* init appearance */
+-      scheme = ecalloc(LENGTH(colors), sizeof(Clr *));
+-      for (i = 0; i < LENGTH(colors); i++)
+-              scheme[i] = drw_scm_create(drw, colors[i], 3);
++      schemes = ecalloc(LENGTH(colors), SchemeN * sizeof(Clr **));
++      for (j = LENGTH(colors) - 1; j >= 0; j--) {
++              scheme = &schemes[j * SchemeN];
++              for (i = 0; i < SchemeN; i++)
++                      scheme[i] = drw_scm_create(drw, colors[j][i], 3);
++      }
+       /* init bars */
+       updatebars();
+       updatestatus();
+-- 
+2.44.0
+
diff --git a/dwm.suckless.org/patches/colorschemes/index.md 
b/dwm.suckless.org/patches/colorschemes/index.md
new file mode 100644
index 00000000..347acd96
--- /dev/null
+++ b/dwm.suckless.org/patches/colorschemes/index.md
@@ -0,0 +1,23 @@
+colorschemes
+============
+
+Description
+-----------
+This patches provides the ability to cycle between any number of colorschemes
+defined in config.h.
+
+Usage
+-----
+Append alternative colorschemes to the `colors[]` array.
+
+Default keybindings
+--------------------
+* `s` - Cycle between colorschemes.
+
+Download
+--------
+* [dwm-colorschemes-6.5.diff](dwm-colorschemes-6.5.diff) (2024-04-22)
+
+Authors
+-------
+* Listeria monocytogenes <[email protected]>


Reply via email to