mirror of
https://github.com/mintycube/dwm.git
synced 2024-10-22 14:05:45 +02:00
Adding vtcolors patch
This commit is contained in:
parent
9ef44a0bc1
commit
4b45c6071f
@ -15,7 +15,7 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
|
||||
|
||||
### Changelog:
|
||||
|
||||
2020-02-11 - Added swaptags patch
|
||||
2020-02-11 - Added swaptags and vtcolor patches
|
||||
|
||||
2020-02-09 - Added alternative scratchpad patch
|
||||
|
||||
@ -373,6 +373,9 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
|
||||
- [viewontag](https://dwm.suckless.org/patches/viewontag/)
|
||||
- follow a window to the tag it is being moved to
|
||||
|
||||
- [vtcolor](https://dwm.suckless.org/patches/vtcolors/)
|
||||
- this patch adds the ability for dwm to read colors from the linux virtual console essentially allowing you to use the same color scheme as your regular tty
|
||||
|
||||
- [warp](https://dwm.suckless.org/patches/warp/)
|
||||
- warps the mouse cursor to the center of the currently focused window or screen when the mouse cursor is (a) on a different screen or (b) on top of a different window
|
||||
|
||||
|
104
config.def.h
104
config.def.h
@ -44,13 +44,16 @@ static const char dmenufont[] = "monospace:size=10";
|
||||
|
||||
static char normfgcolor[] = "#bbbbbb";
|
||||
static char normbgcolor[] = "#222222";
|
||||
#if !VTCOLORS_PATCH
|
||||
static char normbordercolor[] = "#444444";
|
||||
#if FLOAT_BORDER_COLOR_PATCH
|
||||
static char normfloatcolor[] = "#db8fd9";
|
||||
#endif // FLOAT_BORDER_COLOR_PATCH
|
||||
#endif // !VTCOLORS_PATCH
|
||||
|
||||
static char selfgcolor[] = "#eeeeee";
|
||||
static char selbgcolor[] = "#005577";
|
||||
#if !VTCOLORS_PATCH
|
||||
static char selbordercolor[] = "#005577";
|
||||
#if FLOAT_BORDER_COLOR_PATCH
|
||||
static char selfloatcolor[] = "#005577";
|
||||
@ -91,6 +94,7 @@ static char titlebordercolor[] = "#005577";
|
||||
static char titlefloatcolor[] = "#005577";
|
||||
#endif // FLOAT_BORDER_COLOR_PATCH
|
||||
#endif // TITLECOLOR_PATCH
|
||||
#endif // VTCOLORS_PATCH
|
||||
|
||||
#if ALPHA_PATCH
|
||||
static const unsigned int baralpha = 0xd0;
|
||||
@ -108,12 +112,100 @@ static const unsigned int alphas[][3] = {
|
||||
#if AWESOMEBAR_PATCH
|
||||
[SchemeHid] = { OPAQUE, baralpha, borderalpha },
|
||||
#endif // AWESOMEBAR_PATCH
|
||||
#if TITLECOLOR_PATCH
|
||||
#if VTCOLORS_PATCH
|
||||
[SchemeTagsNorm] = { OPAQUE, baralpha, borderalpha },
|
||||
[SchemeTagsSel] = { OPAQUE, baralpha, borderalpha },
|
||||
[SchemeTitleNorm] = { OPAQUE, baralpha, borderalpha },
|
||||
[SchemeTitleSel] = { OPAQUE, baralpha, borderalpha },
|
||||
[SchemeStatus] = { OPAQUE, baralpha, borderalpha },
|
||||
#elif TITLECOLOR_PATCH
|
||||
[SchemeTitle] = { OPAQUE, baralpha, borderalpha },
|
||||
#endif // TITLECOLOR_PATCH
|
||||
#endif // VTCOLORS_PATCH / TITLECOLOR_PATCH
|
||||
};
|
||||
#endif // ALPHA_PATCH
|
||||
#if FLOAT_BORDER_COLOR_PATCH
|
||||
#if VTCOLORS_PATCH && FLOAT_BORDER_COLOR_PATCH
|
||||
static const char title_bg_dark[] = "#303030";
|
||||
static const char title_bg_light[] = "#fdfdfd";
|
||||
static const int color_ptrs[][4] = {
|
||||
/* fg bg border float */
|
||||
[SchemeNorm] = { -1, -1, 5, 12 },
|
||||
[SchemeSel] = { -1, -1, 11, 13 },
|
||||
#if STATUSCOLORS_PATCH
|
||||
[SchemeWarn] = { -1, 1, 1, 14 },
|
||||
#endif // STATUSCOLORS_PATCH
|
||||
#if URGENTBORDER_PATCH || STATUSCOLORS_PATCH
|
||||
[SchemeUrg] = { 7, 9, 9, 15 },
|
||||
#endif // URGENTBORDER_PATCH || STATUSCOLORS_PATCH
|
||||
#if AWESOMEBAR_PATCH
|
||||
[SchemeHid] = { 5, 0, 0, -1 },
|
||||
#endif // AWESOMEBAR_PATCH
|
||||
[SchemeTagsNorm] = { 2, 0, 0, -1 },
|
||||
[SchemeTagsSel] = { 6, 5, 5, -1 },
|
||||
[SchemeTitleNorm] = { 6, -1, -1, -1 },
|
||||
[SchemeTitleSel] = { 6, -1, -1, -1 },
|
||||
[SchemeStatus] = { 2, 0, 0, -1 },
|
||||
};
|
||||
static char colors[][4][8] = {
|
||||
/* fg bg border float */
|
||||
[SchemeNorm] = { "#000000", "#000000", "#000000", "#000000" },
|
||||
[SchemeSel] = { "#000000", "#000000", "#000000", "#000000" },
|
||||
#if STATUSCOLORS_PATCH
|
||||
[SchemeWarn] = { "#000000", "#000000", "#000000", "#000000" },
|
||||
#endif // STATUSCOLORS_PATCH
|
||||
#if URGENTBORDER_PATCH || STATUSCOLORS_PATCH
|
||||
[SchemeUrg] = { "#000000", "#000000", "#000000", "#000000" },
|
||||
#endif // URGENTBORDER_PATCH || STATUSCOLORS_PATCH
|
||||
#if AWESOMEBAR_PATCH
|
||||
[SchemeHid] = { "#000000", "#000000", "#000000", "#000000" },
|
||||
#endif // AWESOMEBAR_PATCH
|
||||
[SchemeTagsNorm] = { "#000000", "#000000", "#000000", "#000000" },
|
||||
[SchemeTagsSel] = { "#000000", "#000000", "#000000", "#000000" },
|
||||
[SchemeTitleNorm] = { "#000000", "#000000", "#000000", "#000000" },
|
||||
[SchemeTitleSel] = { "#000000", "#000000", "#000000", "#000000" },
|
||||
[SchemeStatus] = { "#000000", "#000000", "#000000", "#000000" },
|
||||
};
|
||||
#elif VTCOLORS_PATCH
|
||||
static const char title_bg_dark[] = "#303030";
|
||||
static const char title_bg_light[] = "#fdfdfd";
|
||||
static const int color_ptrs[][3] = {
|
||||
/* fg bg border */
|
||||
[SchemeNorm] = { -1, -1, 5 },
|
||||
[SchemeSel] = { -1, -1, 11 },
|
||||
#if STATUSCOLORS_PATCH
|
||||
[SchemeWarn] = { -1, 1, 1 },
|
||||
#endif // STATUSCOLORS_PATCH
|
||||
#if URGENTBORDER_PATCH || STATUSCOLORS_PATCH
|
||||
[SchemeUrg] = { 7, 9, 9 },
|
||||
#endif // URGENTBORDER_PATCH || STATUSCOLORS_PATCH
|
||||
#if AWESOMEBAR_PATCH
|
||||
[SchemeHid] = { 5, 0, 0 },
|
||||
#endif // AWESOMEBAR_PATCH
|
||||
[SchemeTagsNorm] = { 2, 0, 0 },
|
||||
[SchemeTagsSel] = { 6, 5, 5 },
|
||||
[SchemeTitleNorm] = { 6, -1, -1 },
|
||||
[SchemeTitleSel] = { 6, -1, -1 },
|
||||
[SchemeStatus] = { 2, 0, 0 },
|
||||
};
|
||||
static char colors[][3][8] = {
|
||||
/* fg bg border */
|
||||
[SchemeNorm] = { "#000000", "#000000", "#000000" },
|
||||
[SchemeSel] = { "#000000", "#000000", "#000000" },
|
||||
#if STATUSCOLORS_PATCH
|
||||
[SchemeWarn] = { "#000000", "#000000", "#000000" },
|
||||
#endif // STATUSCOLORS_PATCH
|
||||
#if URGENTBORDER_PATCH || STATUSCOLORS_PATCH
|
||||
[SchemeUrg] = { "#000000", "#000000", "#000000" },
|
||||
#endif // URGENTBORDER_PATCH || STATUSCOLORS_PATCH
|
||||
#if AWESOMEBAR_PATCH
|
||||
[SchemeHid] = { "#000000", "#000000", "#000000" },
|
||||
#endif // AWESOMEBAR_PATCH
|
||||
[SchemeTagsNorm] = { "#000000", "#000000", "#000000" },
|
||||
[SchemeTagsSel] = { "#000000", "#000000", "#000000" },
|
||||
[SchemeTitleNorm] = { "#000000", "#000000", "#000000" },
|
||||
[SchemeTitleSel] = { "#000000", "#000000", "#000000" },
|
||||
[SchemeStatus] = { "#000000", "#000000", "#000000" },
|
||||
};
|
||||
#elif FLOAT_BORDER_COLOR_PATCH
|
||||
static
|
||||
#if !XRDB_PATCH
|
||||
const
|
||||
@ -135,7 +227,7 @@ char *colors[][4] = {
|
||||
[SchemeTitle] = { titlefgcolor, titlebgcolor, titlebordercolor, titlefloatcolor },
|
||||
#endif // TITLECOLOR_PATCH
|
||||
};
|
||||
#else
|
||||
#else // !VTCOLORS_PATCH && !FLOAT_BORDER_COLOR_PATCH
|
||||
static
|
||||
#if !XRDB_PATCH
|
||||
const
|
||||
@ -157,7 +249,7 @@ char *colors[][3] = {
|
||||
[SchemeTitle] = { titlefgcolor, titlebgcolor, titlebordercolor },
|
||||
#endif // TITLECOLOR_PATCH
|
||||
};
|
||||
#endif // FLOAT_BORDER_COLOR_PATCH
|
||||
#endif // VTCOLORS_PATCH / FLOAT_BORDER_COLOR_PATCH
|
||||
|
||||
/* tagging */
|
||||
#if EWMHTAGS_PATCH
|
||||
@ -671,7 +763,7 @@ static Key keys[] = {
|
||||
#if WINVIEW_PATCH
|
||||
{ MODKEY, XK_o, winview, {0} },
|
||||
#endif // WINVIEW_PATCH
|
||||
#if XRDB_PATCH
|
||||
#if XRDB_PATCH && !VTCOLORS_PATCH
|
||||
{ MODKEY|ShiftMask, XK_F5, xrdb, {.v = NULL } },
|
||||
#endif // XRDB_PATCH
|
||||
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
|
||||
|
20
drw.c
20
drw.c
@ -211,12 +211,18 @@ drw_fontset_free(Fnt *font)
|
||||
}
|
||||
|
||||
void
|
||||
#if ALPHA_PATCH
|
||||
drw_clr_create(Drw *drw, Clr *dest, const char *clrname, unsigned int alpha)
|
||||
drw_clr_create(
|
||||
Drw *drw,
|
||||
Clr *dest,
|
||||
#if VTCOLORS_PATCH
|
||||
const char clrname[]
|
||||
#else
|
||||
drw_clr_create(Drw *drw, Clr *dest, const char *clrname)
|
||||
const char *clrname
|
||||
#endif // VTCOLORS_PATCH
|
||||
#if ALPHA_PATCH
|
||||
, unsigned int alpha
|
||||
#endif // ALPHA_PATCH
|
||||
{
|
||||
) {
|
||||
if (!drw || !dest || !clrname)
|
||||
return;
|
||||
|
||||
@ -239,11 +245,13 @@ drw_clr_create(Drw *drw, Clr *dest, const char *clrname)
|
||||
Clr *
|
||||
drw_scm_create(
|
||||
Drw *drw,
|
||||
#if XRDB_PATCH
|
||||
#if VTCOLORS_PATCH
|
||||
char clrnames[][8],
|
||||
#elif XRDB_PATCH
|
||||
char *clrnames[],
|
||||
#else
|
||||
const char *clrnames[],
|
||||
#endif // XRDB_PATCH
|
||||
#endif // VTCOLORS_PATCH / XRDB_PATCH
|
||||
#if ALPHA_PATCH
|
||||
const unsigned int alphas[],
|
||||
#endif // ALPHA_PATCH
|
||||
|
10
drw.h
10
drw.h
@ -54,18 +54,24 @@ void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned in
|
||||
void drw_clr_create(
|
||||
Drw *drw,
|
||||
Clr *dest,
|
||||
#if VTCOLORS_PATCH
|
||||
const char clrname[]
|
||||
#else
|
||||
const char *clrname
|
||||
#endif // VTCOLORS_PATCH
|
||||
#if ALPHA_PATCH
|
||||
, unsigned int alpha
|
||||
#endif // ALPHA_PATCH
|
||||
);
|
||||
Clr *drw_scm_create(
|
||||
Drw *drw,
|
||||
#if XRDB_PATCH
|
||||
#if VTCOLORS_PATCH
|
||||
char clrnames[][8],
|
||||
#elif XRDB_PATCH
|
||||
char *clrnames[],
|
||||
#else
|
||||
const char *clrnames[],
|
||||
#endif // XRDB_PATCH
|
||||
#endif // VTCOLORS_PATCH / XRDB_PATCH
|
||||
#if ALPHA_PATCH
|
||||
const unsigned int alphas[],
|
||||
#endif // ALPHA_PATCH
|
||||
|
89
dwm.c
89
dwm.c
@ -93,9 +93,15 @@ enum {
|
||||
#if AWESOMEBAR_PATCH
|
||||
,SchemeHid
|
||||
#endif // AWESOMEBAR_PATCH
|
||||
#if TITLECOLOR_PATCH
|
||||
#if VTCOLORS_PATCH
|
||||
,SchemeTagsNorm
|
||||
,SchemeTagsSel
|
||||
,SchemeTitleNorm
|
||||
,SchemeTitleSel
|
||||
,SchemeStatus
|
||||
#elif TITLECOLOR_PATCH
|
||||
,SchemeTitle
|
||||
#endif // TITLECOLOR_PATCH
|
||||
#endif // VTCOLORS_PATCH
|
||||
}; /* color schemes */
|
||||
|
||||
enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
|
||||
@ -1359,7 +1365,11 @@ drawbar(Monitor *m)
|
||||
#if !STATUSALLMONS_PATCH
|
||||
if (m == selmon) { /* status is only drawn on selected monitor */
|
||||
#endif // STATUSALLMONS_PATCH
|
||||
#if VTCOLORS_PATCH
|
||||
drw_setscheme(drw, scheme[SchemeStatus]);
|
||||
#else
|
||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||
#endif // VTCOLORS_PATCH
|
||||
#if STATUSPADDING_PATCH
|
||||
sw = TEXTW(stext);
|
||||
#else
|
||||
@ -1405,7 +1415,11 @@ drawbar(Monitor *m)
|
||||
x = 0;
|
||||
#if LEFTLAYOUT_PATCH
|
||||
w = blw = TEXTW(m->ltsymbol);
|
||||
#if VTCOLORS_PATCH
|
||||
drw_setscheme(drw, scheme[SchemeTagsNorm]);
|
||||
#else
|
||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||
#endif // VTCOLORS_PATCH
|
||||
x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0);
|
||||
#endif // LEFTLAYOUT_PATCH
|
||||
#if TAGGRID_PATCH
|
||||
@ -1428,9 +1442,19 @@ drawbar(Monitor *m)
|
||||
#endif // ALTERNATIVE_TAGS_PATCH
|
||||
#if URGENTBORDER_PATCH
|
||||
if (m->tagset[m->seltags] & 1 << i)
|
||||
#if VTCOLORS_PATCH
|
||||
drw_setscheme(drw, scheme[SchemeTagsSel]);
|
||||
#else
|
||||
drw_setscheme(drw, scheme[SchemeSel]);
|
||||
#endif // VTCOLORS_PATCH
|
||||
else
|
||||
#if VTCOLORS_PATCH
|
||||
drw_setscheme(drw, scheme[urg & 1 << i ? SchemeUrg : SchemeTagsNorm]);
|
||||
#else
|
||||
drw_setscheme(drw, scheme[urg & 1 << i ? SchemeUrg : SchemeNorm]);
|
||||
#endif // VTCOLORS_PATCH
|
||||
#elif VTCOLORS_PATCH
|
||||
drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeTagsSel : SchemeTagsNorm]);
|
||||
#else // URGENTBORDER_PATCH
|
||||
drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
|
||||
#endif // URGENTBORDER_PATCH
|
||||
@ -1457,7 +1481,11 @@ drawbar(Monitor *m)
|
||||
#endif // TAGGRID_PATCH
|
||||
#if !LEFTLAYOUT_PATCH
|
||||
w = blw = TEXTW(m->ltsymbol);
|
||||
#if VTCOLORS_PATCH
|
||||
drw_setscheme(drw, scheme[SchemeTagsNorm]);
|
||||
#else
|
||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||
#endif // VTCOLORS_PATCH
|
||||
x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0);
|
||||
#endif // LEFTLAYOUT_PATCH
|
||||
|
||||
@ -1469,22 +1497,32 @@ drawbar(Monitor *m)
|
||||
if (!ISVISIBLE(c))
|
||||
continue;
|
||||
if (m->sel == c)
|
||||
#if TITLECOLOR_PATCH
|
||||
#if VTCOLORS_PATCH
|
||||
scm = SchemeTitleSel;
|
||||
#elif TITLECOLOR_PATCH
|
||||
scm = SchemeTitle;
|
||||
#else
|
||||
scm = SchemeSel;
|
||||
#endif // TITLECOLOR_PATCH
|
||||
#endif // VTCOLORS_PATCH / TITLECOLOR_PATCH
|
||||
else if (HIDDEN(c))
|
||||
scm = SchemeHid;
|
||||
else
|
||||
#if VTCOLORS_PATCH
|
||||
scm = SchemeTitleNorm;
|
||||
#else
|
||||
scm = SchemeNorm;
|
||||
#endif // VTCOLORS_PATCH
|
||||
|
||||
drw_setscheme(drw, scheme[scm]);
|
||||
drw_text(drw, x, 0, (1.0 / (double)n) * w, bh, lrpad / 2, c->name, 0);
|
||||
x += (1.0 / (double)n) * w;
|
||||
}
|
||||
} else {
|
||||
#if VTCOLORS_PATCH
|
||||
drw_setscheme(drw, scheme[SchemeTitleNorm]);
|
||||
#else
|
||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||
#endif // VTCOLORS_PATCH
|
||||
drw_rect(drw, x, 0, w, bh, 1, 1);
|
||||
}
|
||||
#elif FANCYBAR_PATCH
|
||||
@ -1510,11 +1548,13 @@ drawbar(Monitor *m)
|
||||
continue;
|
||||
tw = MIN(m->sel == c ? w : mw, TEXTW(c->name));
|
||||
|
||||
#if TITLECOLOR_PATCH
|
||||
#if VTCOLORS_PATCH
|
||||
drw_setscheme(drw, scheme[m->sel == c ? SchemeTitleSel : SchemeTitleNorm]);
|
||||
#elif TITLECOLOR_PATCH
|
||||
drw_setscheme(drw, scheme[m->sel == c ? SchemeTitle : SchemeNorm]);
|
||||
#else
|
||||
drw_setscheme(drw, scheme[m->sel == c ? SchemeSel : SchemeNorm]);
|
||||
#endif // TITLECOLOR_PATCH
|
||||
#endif // VTCOLORS_PATCH / TITLECOLOR_PATCH
|
||||
if (tw > 0) /* trap special handling of 0 in drw_text */
|
||||
drw_text(drw, x, 0, tw, bh, lrpad / 2, c->name, 0);
|
||||
#if !HIDEVACANTTAGS_PATCH
|
||||
@ -1529,15 +1569,21 @@ drawbar(Monitor *m)
|
||||
w -= tw;
|
||||
}
|
||||
}
|
||||
#if VTCOLORS_PATCH
|
||||
drw_setscheme(drw, scheme[SchemeTitleNorm]);
|
||||
#else
|
||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||
#endif // VTCOLORS_PATCH
|
||||
drw_rect(drw, x, 0, w, bh, 1, 1);
|
||||
#else
|
||||
if (m->sel) {
|
||||
#if TITLECOLOR_PATCH
|
||||
#if VTCOLORS_PATCH
|
||||
drw_setscheme(drw, scheme[m == selmon ? SchemeTitleSel : SchemeTitleNorm]);
|
||||
#elif TITLECOLOR_PATCH
|
||||
drw_setscheme(drw, scheme[m == selmon ? SchemeTitle : SchemeNorm]);
|
||||
#else
|
||||
drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]);
|
||||
#endif // TITLECOLOR_PATCH
|
||||
#endif // VTCOLORS_PATCH / TITLECOLOR_PATCH
|
||||
#if IGNORE_XFT_ERRORS_WHEN_DRAWING_TEXT_PATCH
|
||||
XSetErrorHandler(xerrordummy);
|
||||
#endif // IGNORE_XFT_ERRORS_WHEN_DRAWING_TEXT_PATCH
|
||||
@ -1568,7 +1614,11 @@ drawbar(Monitor *m)
|
||||
#endif // ACTIVETAGINDICATORBAR_PATCH
|
||||
#endif // HIDEVACANTTAGS_PATCH
|
||||
} else {
|
||||
#if VTCOLORS_PATCH
|
||||
drw_setscheme(drw, scheme[SchemeTitleNorm]);
|
||||
#else
|
||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||
#endif // VTCOLORS_PATCH
|
||||
#if BARPADDING_PATCH
|
||||
drw_rect(drw, x, 0, w - 2 * sp, bh, 1, 1);
|
||||
#else
|
||||
@ -1585,7 +1635,11 @@ drawbar(Monitor *m)
|
||||
drw_map(drw, m->barwin, 0, 0, m->ww - stw, bh);
|
||||
#if EXTRABAR_PATCH
|
||||
if (m == selmon) { /* extra status is only drawn on selected monitor */
|
||||
#if VTCOLORS_PATCH
|
||||
drw_setscheme(drw, scheme[SchemeTitleNorm]);
|
||||
#else
|
||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||
#endif // VTCOLORS_PATCH
|
||||
drw_text(drw, 0, 0, mons->ww, bh, 0, estext, 0);
|
||||
drw_map(drw, m->extrabarwin, 0, 0, m->ww, bh);
|
||||
}
|
||||
@ -2922,6 +2976,16 @@ setup(void)
|
||||
cursor[CurResize] = drw_cur_create(drw, XC_sizing);
|
||||
cursor[CurMove] = drw_cur_create(drw, XC_fleur);
|
||||
/* init appearance */
|
||||
#if VTCOLORS_PATCH
|
||||
get_vt_colors();
|
||||
if (get_luminance(colors[SchemeTagsNorm][ColBg]) > 50) {
|
||||
strcpy(colors[SchemeTitleNorm][ColBg], title_bg_light);
|
||||
strcpy(colors[SchemeTitleSel][ColBg], title_bg_light);
|
||||
} else {
|
||||
strcpy(colors[SchemeTitleNorm][ColBg], title_bg_dark);
|
||||
strcpy(colors[SchemeTitleSel][ColBg], title_bg_dark);
|
||||
}
|
||||
#endif // VTCOLORS_PATCH
|
||||
scheme = ecalloc(LENGTH(colors), sizeof(Clr *));
|
||||
for (i = 0; i < LENGTH(colors); i++)
|
||||
scheme[i] = drw_scm_create(drw, colors[i],
|
||||
@ -3983,6 +4047,7 @@ main(int argc, char *argv[])
|
||||
die(help());
|
||||
else if (!strcmp("-fn", argv[i])) /* font set */
|
||||
fonts[0] = argv[++i];
|
||||
#if !VTCOLORS_PATCH
|
||||
else if (!strcmp("-nb", argv[i])) /* normal background color */
|
||||
colors[SchemeNorm][1] = argv[++i];
|
||||
else if (!strcmp("-nf", argv[i])) /* normal foreground color */
|
||||
@ -3991,6 +4056,7 @@ main(int argc, char *argv[])
|
||||
colors[SchemeSel][1] = argv[++i];
|
||||
else if (!strcmp("-sf", argv[i])) /* selected foreground color */
|
||||
colors[SchemeSel][0] = argv[++i];
|
||||
#endif // !VTCOLORS_PATCH
|
||||
#if NODMENU_PATCH
|
||||
else if (!strcmp("-df", argv[i])) /* dmenu font */
|
||||
dmenucmd[2] = argv[++i];
|
||||
@ -4002,7 +4068,6 @@ main(int argc, char *argv[])
|
||||
dmenucmd[8] = argv[++i];
|
||||
else if (!strcmp("-dsf", argv[i])) /* dmenu selected foreground color */
|
||||
dmenucmd[10] = argv[++i];
|
||||
else die(help());
|
||||
#else
|
||||
else if (!strcmp("-df", argv[i])) /* dmenu font */
|
||||
dmenucmd[4] = argv[++i];
|
||||
@ -4014,8 +4079,8 @@ main(int argc, char *argv[])
|
||||
dmenucmd[10] = argv[++i];
|
||||
else if (!strcmp("-dsf", argv[i])) /* dmenu selected foreground color */
|
||||
dmenucmd[12] = argv[++i];
|
||||
else die(help());
|
||||
#endif // NODMENU_PATCH
|
||||
else die(help());
|
||||
#else
|
||||
if (argc == 2 && !strcmp("-v", argv[1]))
|
||||
die("dwm-"VERSION);
|
||||
@ -4031,10 +4096,10 @@ main(int argc, char *argv[])
|
||||
die("dwm: cannot get xcb connection\n");
|
||||
#endif // SWALLOW_PATCH
|
||||
checkotherwm();
|
||||
#if XRDB_PATCH
|
||||
#if XRDB_PATCH && !VTCOLORS_PATCH
|
||||
XrmInitialize();
|
||||
loadxrdb();
|
||||
#endif
|
||||
#endif // XRDB_PATCH && !VTCOLORS_PATCH
|
||||
|
||||
setup();
|
||||
#ifdef __OpenBSD__
|
||||
|
@ -146,6 +146,9 @@
|
||||
#if VANITYGAPS_PATCH
|
||||
#include "vanitygaps.c"
|
||||
#endif
|
||||
#if VTCOLORS_PATCH
|
||||
#include "vtcolors.c"
|
||||
#endif
|
||||
#if WARP_PATCH
|
||||
#include "warp.c"
|
||||
#endif
|
||||
@ -155,7 +158,7 @@
|
||||
#if ZOOMSWAP_PATCH
|
||||
#include "zoomswap.c"
|
||||
#endif
|
||||
#if XRDB_PATCH
|
||||
#if XRDB_PATCH && !VTCOLORS_PATCH
|
||||
#include "xrdb.c"
|
||||
#endif
|
||||
/* Layouts */
|
||||
|
@ -146,6 +146,9 @@
|
||||
#if VANITYGAPS_PATCH
|
||||
#include "vanitygaps.h"
|
||||
#endif
|
||||
#if VTCOLORS_PATCH
|
||||
#include "vtcolors.h"
|
||||
#endif
|
||||
#if WARP_PATCH
|
||||
#include "warp.h"
|
||||
#endif
|
||||
@ -155,7 +158,7 @@
|
||||
#if ZOOMSWAP_PATCH
|
||||
#include "zoomswap.h"
|
||||
#endif
|
||||
#if XRDB_PATCH
|
||||
#if XRDB_PATCH && !VTCOLORS_PATCH
|
||||
#include "xrdb.h"
|
||||
#endif
|
||||
/* Layouts */
|
||||
|
70
patch/vtcolors.c
Normal file
70
patch/vtcolors.c
Normal file
@ -0,0 +1,70 @@
|
||||
void
|
||||
get_vt_colors(void)
|
||||
{
|
||||
char *cfs[3] = {
|
||||
"/sys/module/vt/parameters/default_red",
|
||||
"/sys/module/vt/parameters/default_grn",
|
||||
"/sys/module/vt/parameters/default_blu",
|
||||
};
|
||||
char vtcs[16][8];
|
||||
char tk[] = ",";
|
||||
char cl[64];
|
||||
char *tp = NULL;
|
||||
FILE *fp;
|
||||
size_t r;
|
||||
int i, c, n;
|
||||
|
||||
for (i = 0; i < 16; i++)
|
||||
strcpy(vtcs[i], "#000000");
|
||||
|
||||
for (i = 0, r = 0; i < 3; i++) {
|
||||
if ((fp = fopen(cfs[i], "r")) == NULL)
|
||||
continue;
|
||||
while ((cl[r] = fgetc(fp)) != EOF && cl[r] != '\n')
|
||||
r++;
|
||||
cl[r] = '\0';
|
||||
for (c = 0, tp = cl, n = 0; c < 16; c++, tp++) {
|
||||
if ((r = strcspn(tp, tk)) == -1)
|
||||
break;
|
||||
for (n = 0; r && *tp >= 48 && *tp < 58; r--, tp++)
|
||||
n = n * 10 - 48 + *tp;
|
||||
vtcs[c][i * 2 + 1] = n / 16 < 10 ? n / 16 + 48 : n / 16 + 87;
|
||||
vtcs[c][i * 2 + 2] = n % 16 < 10 ? n % 16 + 48 : n % 16 + 87;
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
for (i = 0; i < LENGTH(colors); i++) {
|
||||
#if FLOAT_BORDER_COLOR_PATCH
|
||||
for (c = 0; c < 4; c++)
|
||||
#else
|
||||
for (c = 0; c < 3; c++)
|
||||
#endif // FLOAT_BORDER_COLOR_PATCH
|
||||
{
|
||||
n = color_ptrs[i][c];
|
||||
if (n > -1 && strlen(colors[i][c]) >= strlen(vtcs[n]))
|
||||
memcpy(colors[i][c], vtcs[n], 7);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int get_luminance(char *r)
|
||||
{
|
||||
char *c = r;
|
||||
int n[3] = {0};
|
||||
int i = 0;
|
||||
|
||||
while (*c) {
|
||||
if (*c >= 48 && *c < 58)
|
||||
n[i / 2] = n[i / 2] * 16 - 48 + *c;
|
||||
else if (*c >= 65 && *c < 71)
|
||||
n[i / 2] = n[i / 2] * 16 - 55 + *c;
|
||||
else if (*c >= 97 && *c < 103)
|
||||
n[i / 2] = n[i / 2] * 16 - 87 + *c;
|
||||
else
|
||||
i--;
|
||||
i++;
|
||||
c++;
|
||||
}
|
||||
|
||||
return (0.299 * n[0] + 0.587 * n[1] + 0.114 * n[2]) / 2.55;
|
||||
}
|
2
patch/vtcolors.h
Normal file
2
patch/vtcolors.h
Normal file
@ -0,0 +1,2 @@
|
||||
static void get_vt_colors(void);
|
||||
static int get_luminance(char *rgb);
|
@ -585,6 +585,13 @@
|
||||
*/
|
||||
#define VIEWONTAG_PATCH 0
|
||||
|
||||
/* This patch adds the ability for dwm to read colors from the linux virtual console.
|
||||
* /sys/module/vt/parameters/default_{red,grn,blu}
|
||||
* Essentially this way the colors you use in your regular tty is "mirrored" to dwm.
|
||||
* https://dwm.suckless.org/patches/vtcolors/
|
||||
*/
|
||||
#define VTCOLORS_PATCH 0
|
||||
|
||||
/* This patch warps the mouse cursor to the center of the currently focused window or screen
|
||||
* when the mouse cursor is (a) on a different screen or (b) on top of a different window.
|
||||
* https://dwm.suckless.org/patches/warp/
|
||||
|
Loading…
Reference in New Issue
Block a user