commit a9d57482446dbd4f5bdb4463d8121c5522ef9265
Author: tdu <tdukv_AT_protonmail.com>
Date: Thu Aug 27 17:34:10 2020 +0300
Extra patches to go on top of the status2d patch.
- xrdb - colors can be set as [0:15] terminal colors, and dynamically changed from xrdb
- swap-save-restore - extra commands for changing statusbar colors.
diff --git a/dwm.suckless.org/patches/status2d/dwm-status2d-swap-save-restore-6.2.diff b/dwm.suckless.org/patches/status2d/dwm-status2d-swap-save-restore-6.2.diff
new file mode 100644
index 00000000..b4b60ec8
--- /dev/null
+++ b/dwm.suckless.org/patches/status2d/dwm-status2d-swap-save-restore-6.2.diff
_AT_@ -0,0 +1,44 @@
+From dfd158c8dea87a0a4dbc5b2eda7c096069d1484a Mon Sep 17 00:00:00 2001
+From: tdu <tdukv_AT_protonmail.com>
+Date: Wed, 26 Aug 2020 18:50:09 +0300
+Subject: [PATCH] Add the following tags for the status2d patch: ^w^ -
+ Swaps bg/fg color. ^v^ - Saves the current fg/bg color. ^t^ - Restores
+ the previously saved bg/fg color.
+
+---
+ dwm.c | 12 ++++++++++++
+ 1 file changed, 12 insertions(+)
+
+diff --git a/dwm.c b/dwm.c
+index 931044f..de07b66 100644
+--- a/dwm.c
++++ b/dwm.c
+_AT_@ -699,6 +699,7 @@ drawstatusbar(Monitor *m, int bh, char* stext) {
+ short isCode = 0;
+ char *text;
+ char *p;
++ Clr oldbg, oldfg;
+
+ len = strlen(stext) + 1 ;
+ if (!(text = (char*) malloc(sizeof(char)*len)))
+_AT_@ -769,6 +770,17 @@ drawstatusbar(Monitor *m, int bh, char* stext) {
+ } else if (text[i] == 'd') {
+ drw->scheme[ColFg] = scheme[SchemeNorm][ColFg];
+ drw->scheme[ColBg] = scheme[SchemeNorm][ColBg];
++ } else if (text[i] == 'w') {
++ Clr swp;
++ swp = drw->scheme[ColFg];
++ drw->scheme[ColFg] = drw->scheme[ColBg];
++ drw->scheme[ColBg] = swp;
++ } else if (text[i] == 'v') {
++ oldfg = drw->scheme[ColFg];
++ oldbg = drw->scheme[ColBg];
++ } else if (text[i] == 't') {
++ drw->scheme[ColFg] = oldfg;
++ drw->scheme[ColBg] = oldbg;
+ } else if (text[i] == 'r') {
+ int rx = atoi(text + ++i);
+ while (text[++i] != ',');
+--
+2.28.0
+
diff --git a/dwm.suckless.org/patches/status2d/dwm-status2d-xrdb-6.2.diff b/dwm.suckless.org/patches/status2d/dwm-status2d-xrdb-6.2.diff
new file mode 100644
index 00000000..1f22aa58
--- /dev/null
+++ b/dwm.suckless.org/patches/status2d/dwm-status2d-xrdb-6.2.diff
_AT_@ -0,0 +1,100 @@
+From bd7dd6d06e8b8c9dd6b595b2ce5f6e88b9565311 Mon Sep 17 00:00:00 2001
+From: tdu <tdukv_AT_protonmail.com>
+Date: Wed, 26 Aug 2020 21:26:21 +0300
+Subject: [PATCH] Use the 16 terminal colors from xrdb for status2d.
+
+^C<num>^ - fg.
+^B<num>^ - bg.
+---
+ config.def.h | 34 ++++++++++++++++++++++++++++++++++
+ dwm.c | 22 ++++++++++++++++++++++
+ 2 files changed, 56 insertions(+)
+
+diff --git a/config.def.h b/config.def.h
+index 5db7d05..46bc6fe 100644
+--- a/config.def.h
++++ b/config.def.h
+_AT_@ -13,6 +13,40 @@ static char normfgcolor[] = "#bbbbbb";
+ static char selfgcolor[] = "#eeeeee";
+ static char selbordercolor[] = "#005577";
+ static char selbgcolor[] = "#005577";
++static char termcol0[] = "#000000"; /* black */
++static char termcol1[] = "#ff0000"; /* red */
++static char termcol2[] = "#33ff00"; /* green */
++static char termcol3[] = "#ff0099"; /* yellow */
++static char termcol4[] = "#0066ff"; /* blue */
++static char termcol5[] = "#cc00ff"; /* magenta */
++static char termcol6[] = "#00ffff"; /* cyan */
++static char termcol7[] = "#d0d0d0"; /* white */
++static char termcol8[] = "#808080"; /* black */
++static char termcol9[] = "#ff0000"; /* red */
++static char termcol10[] = "#33ff00"; /* green */
++static char termcol11[] = "#ff0099"; /* yellow */
++static char termcol12[] = "#0066ff"; /* blue */
++static char termcol13[] = "#cc00ff"; /* magenta */
++static char termcol14[] = "#00ffff"; /* cyan */
++static char termcol15[] = "#ffffff"; /* white */
++static char *termcolor[] = {
++ termcol0,
++ termcol1,
++ termcol2,
++ termcol3,
++ termcol4,
++ termcol5,
++ termcol6,
++ termcol7,
++ termcol8,
++ termcol9,
++ termcol10,
++ termcol11,
++ termcol12,
++ termcol13,
++ termcol14,
++ termcol15,
++};
+ static char *colors[][3] = {
+ /* fg bg border */
+ [SchemeNorm] = { normfgcolor, normbgcolor, normbordercolor },
+diff --git a/dwm.c b/dwm.c
+index 87547f0..601dc1d 100644
+--- a/dwm.c
++++ b/dwm.c
+_AT_@ -784,6 +784,12 @@ drawstatusbar(Monitor *m, int bh, char* stext) {
+ buf[7] = '+ drw_clr_create(drw, &drw->scheme[ColBg], buf);
+ i += 7;
++ } else if (text[i] == 'C') {
++ int c = atoi(text + ++i);
++ drw_clr_create(drw, &drw->scheme[ColFg], termcolor[c]);
++ } else if (text[i] == 'B') {
++ int c = atoi(text + ++i);
++ drw_clr_create(drw, &drw->scheme[ColBg], termcolor[c]);
+ } else if (text[i] == 'd') {
+ drw->scheme[ColFg] = scheme[SchemeNorm][ColFg];
+ drw->scheme[ColBg] = scheme[SchemeNorm][ColBg];
+_AT_@ -1163,6 +1169,22 @@ loadxrdb()
+ XRDB_LOAD_COLOR("dwm.selbordercolor", selbordercolor);
+ XRDB_LOAD_COLOR("dwm.selbgcolor", selbgcolor);
+ XRDB_LOAD_COLOR("dwm.selfgcolor", selfgcolor);
++ XRDB_LOAD_COLOR("color0", termcol0);
++ XRDB_LOAD_COLOR("color1", termcol1);
++ XRDB_LOAD_COLOR("color2", termcol2);
++ XRDB_LOAD_COLOR("color3", termcol3);
++ XRDB_LOAD_COLOR("color4", termcol4);
++ XRDB_LOAD_COLOR("color5", termcol5);
++ XRDB_LOAD_COLOR("color6", termcol6);
++ XRDB_LOAD_COLOR("color7", termcol7);
++ XRDB_LOAD_COLOR("color8", termcol8);
++ XRDB_LOAD_COLOR("color9", termcol9);
++ XRDB_LOAD_COLOR("color10", termcol10);
++ XRDB_LOAD_COLOR("color11", termcol11);
++ XRDB_LOAD_COLOR("color12", termcol12);
++ XRDB_LOAD_COLOR("color13", termcol13);
++ XRDB_LOAD_COLOR("color14", termcol14);
++ XRDB_LOAD_COLOR("color15", termcol15);
+ }
+ }
+ }
+--
+2.28.0
+
diff --git a/dwm.suckless.org/patches/status2d/index.md b/dwm.suckless.org/patches/status2d/index.md
index c685e403..8b3ddfec 100644
--- a/dwm.suckless.org/patches/status2d/index.md
+++ b/dwm.suckless.org/patches/status2d/index.md
_AT_@ -18,6 +18,14 @@ Use this patch if you want to include the extrabar patch
* [dwm-status2d-extrabar-6.2.diff](dwm-status2d-extrabar-6.2.diff)
+This patch adds the ability to use terminal colors from xrdb, allowing programs like pywal to change statusbar colors. Requires [xrdb patch](../xrdb/) as well.
+
+* [dwm-status2d-xrdb-6.2.diff](dwm-status2d-xrdb-6.2.diff)
+
+This patch adds some extra tags for managing colors described below
+
+* [dwm-status2d-swap-save-restore-6.2.diff](dwm-status2d-swap-save-restore-6.2.diff)
+
Usage
-----
* __^rx,y,w,h^__
_AT_@ -40,6 +48,27 @@ Usage
* __^d^__
Reset colors to SchemeNorm.
+
+* __^C<num>^__
+ Set foreground color to terminal color 0-15. Requires the xrdb sub-patch above.
+
+
+* __^B<num>^__
+ Set background color to terminal color 0-15. Requires the xrdb sub-patch above.
+
+
+* __^w^__
+ Swaps the current foreground/background colors. Useful when drawing multiple rectangles on top of one another. Requires the swap-save-restore sub-patch above.
+
+
+* __^v^__
+ Saves the current color scheme so it can be restored later with the __^t^__ tag. This way a script can modify color in the middle of the bar agnostic to what color was set previously. Requires the swap-save-restore sub-patch above.
+
+
+* __^t^__
+ Restores the last color scheme saved by the __^v^__ tag. Requires the swap-save-restore sub-patch above.
+
+
Example
-------
`xsetroot -name "[status2d] ^c#FF0000^red text with blue
_AT_@ -61,4 +90,4 @@ Authors
-------
* [sipi](
https://github.com/sipi)
* lhark - <lhark_AT_ntymail.com> (6.2 port, ^b^ command)
-
+* [tdu](
https://github.com/tdukv) (xrdb colors, ^w^, ^v^, ^t^ commands)
Received on Thu Aug 27 2020 - 16:41:36 CEST