dwm-status2d-xrdb-6.2.diff (3577B)
1 From bd7dd6d06e8b8c9dd6b595b2ce5f6e88b9565311 Mon Sep 17 00:00:00 2001 2 From: tdu <tdukv@protonmail.com> 3 Date: Wed, 26 Aug 2020 21:26:21 +0300 4 Subject: [PATCH] Use the 16 terminal colors from xrdb for status2d. 5 6 ^C<num>^ - fg. 7 ^B<num>^ - bg. 8 --- 9 config.def.h | 34 ++++++++++++++++++++++++++++++++++ 10 dwm.c | 22 ++++++++++++++++++++++ 11 2 files changed, 56 insertions(+) 12 13 diff --git a/config.def.h b/config.def.h 14 index 5db7d05..46bc6fe 100644 15 --- a/config.def.h 16 +++ b/config.def.h 17 @@ -13,6 +13,40 @@ static char normfgcolor[] = "#bbbbbb"; 18 static char selfgcolor[] = "#eeeeee"; 19 static char selbordercolor[] = "#005577"; 20 static char selbgcolor[] = "#005577"; 21 +static char termcol0[] = "#000000"; /* black */ 22 +static char termcol1[] = "#ff0000"; /* red */ 23 +static char termcol2[] = "#33ff00"; /* green */ 24 +static char termcol3[] = "#ff0099"; /* yellow */ 25 +static char termcol4[] = "#0066ff"; /* blue */ 26 +static char termcol5[] = "#cc00ff"; /* magenta */ 27 +static char termcol6[] = "#00ffff"; /* cyan */ 28 +static char termcol7[] = "#d0d0d0"; /* white */ 29 +static char termcol8[] = "#808080"; /* black */ 30 +static char termcol9[] = "#ff0000"; /* red */ 31 +static char termcol10[] = "#33ff00"; /* green */ 32 +static char termcol11[] = "#ff0099"; /* yellow */ 33 +static char termcol12[] = "#0066ff"; /* blue */ 34 +static char termcol13[] = "#cc00ff"; /* magenta */ 35 +static char termcol14[] = "#00ffff"; /* cyan */ 36 +static char termcol15[] = "#ffffff"; /* white */ 37 +static char *termcolor[] = { 38 + termcol0, 39 + termcol1, 40 + termcol2, 41 + termcol3, 42 + termcol4, 43 + termcol5, 44 + termcol6, 45 + termcol7, 46 + termcol8, 47 + termcol9, 48 + termcol10, 49 + termcol11, 50 + termcol12, 51 + termcol13, 52 + termcol14, 53 + termcol15, 54 +}; 55 static char *colors[][3] = { 56 /* fg bg border */ 57 [SchemeNorm] = { normfgcolor, normbgcolor, normbordercolor }, 58 diff --git a/dwm.c b/dwm.c 59 index 87547f0..601dc1d 100644 60 --- a/dwm.c 61 +++ b/dwm.c 62 @@ -784,6 +784,12 @@ drawstatusbar(Monitor *m, int bh, char* stext) { 63 buf[7] = '\0'; 64 drw_clr_create(drw, &drw->scheme[ColBg], buf); 65 i += 7; 66 + } else if (text[i] == 'C') { 67 + int c = atoi(text + ++i); 68 + drw_clr_create(drw, &drw->scheme[ColFg], termcolor[c]); 69 + } else if (text[i] == 'B') { 70 + int c = atoi(text + ++i); 71 + drw_clr_create(drw, &drw->scheme[ColBg], termcolor[c]); 72 } else if (text[i] == 'd') { 73 drw->scheme[ColFg] = scheme[SchemeNorm][ColFg]; 74 drw->scheme[ColBg] = scheme[SchemeNorm][ColBg]; 75 @@ -1163,6 +1169,22 @@ loadxrdb() 76 XRDB_LOAD_COLOR("dwm.selbordercolor", selbordercolor); 77 XRDB_LOAD_COLOR("dwm.selbgcolor", selbgcolor); 78 XRDB_LOAD_COLOR("dwm.selfgcolor", selfgcolor); 79 + XRDB_LOAD_COLOR("color0", termcol0); 80 + XRDB_LOAD_COLOR("color1", termcol1); 81 + XRDB_LOAD_COLOR("color2", termcol2); 82 + XRDB_LOAD_COLOR("color3", termcol3); 83 + XRDB_LOAD_COLOR("color4", termcol4); 84 + XRDB_LOAD_COLOR("color5", termcol5); 85 + XRDB_LOAD_COLOR("color6", termcol6); 86 + XRDB_LOAD_COLOR("color7", termcol7); 87 + XRDB_LOAD_COLOR("color8", termcol8); 88 + XRDB_LOAD_COLOR("color9", termcol9); 89 + XRDB_LOAD_COLOR("color10", termcol10); 90 + XRDB_LOAD_COLOR("color11", termcol11); 91 + XRDB_LOAD_COLOR("color12", termcol12); 92 + XRDB_LOAD_COLOR("color13", termcol13); 93 + XRDB_LOAD_COLOR("color14", termcol14); 94 + XRDB_LOAD_COLOR("color15", termcol15); 95 } 96 } 97 } 98 -- 99 2.28.0 100