add colorschemes for powerline status

This commit is contained in:
speedie 2022-12-05 17:25:49 +01:00
parent 97a5c9c831
commit c1fccc16a8
2 changed files with 58 additions and 23 deletions

View file

@ -22,6 +22,27 @@ static char *colors[][3] = {
/* text background window border */
};
/* Colors for the status if powerline status is used */
static char *powerlinecolors[][3] = {
[SchemePowerline1] = { col_textsel, col_status0, NULL },
[SchemePowerline2] = { col_textnorm, col_status1, NULL },
[SchemePowerline3] = { col_textnorm, col_status2, NULL },
[SchemePowerline4] = { col_textnorm, col_status3, NULL },
[SchemePowerline5] = { col_textnorm, col_status4, NULL },
[SchemePowerline6] = { col_textnorm, col_status5, NULL },
[SchemePowerline7] = { col_textnorm, col_status6, NULL },
[SchemePowerline8] = { col_textnorm, col_status7, NULL },
[SchemePowerline9] = { col_textnorm, col_status8, NULL },
[SchemePowerline10] = { col_textnorm, col_status9, NULL },
[SchemePowerline11] = { col_textnorm, col_status10, NULL },
[SchemePowerline12] = { col_textnorm, col_status11, NULL },
[SchemePowerline13] = { col_textnorm, col_status12, NULL },
[SchemePowerline14] = { col_textnorm, col_status13, NULL },
[SchemePowerline15] = { col_textnorm, col_status14, NULL },
[SchemePowerline16] = { col_textnorm, col_status15, NULL },
/* text powerline color unused */
};
/* Colors for the status bar (.Xresources) */
static char *colstatus[] = {
col_status0,
@ -58,6 +79,22 @@ static unsigned int alphas[][3] = {
[SchemeTagsSel] = { tagselopacity, tagselopacity, tagnormopacity },
[SchemeTagsUrg] = { tagselopacity, tagselopacity, tagnormopacity },
[SchemeSystray] = { opaque, systrayopacity, systrayopacity },
[SchemePowerline1] = { opaque, statusopacity, statusopacity },
[SchemePowerline2] = { opaque, statusopacity, statusopacity },
[SchemePowerline3] = { opaque, statusopacity, statusopacity },
[SchemePowerline4] = { opaque, statusopacity, statusopacity },
[SchemePowerline5] = { opaque, statusopacity, statusopacity },
[SchemePowerline6] = { opaque, statusopacity, statusopacity },
[SchemePowerline7] = { opaque, statusopacity, statusopacity },
[SchemePowerline8] = { opaque, statusopacity, statusopacity },
[SchemePowerline9] = { opaque, statusopacity, statusopacity },
[SchemePowerline10] = { opaque, statusopacity, statusopacity },
[SchemePowerline11] = { opaque, statusopacity, statusopacity },
[SchemePowerline12] = { opaque, statusopacity, statusopacity },
[SchemePowerline13] = { opaque, statusopacity, statusopacity },
[SchemePowerline14] = { opaque, statusopacity, statusopacity },
[SchemePowerline15] = { opaque, statusopacity, statusopacity },
[SchemePowerline16] = { opaque, statusopacity, statusopacity },
};
/* Colors to use for tags */
@ -71,7 +108,7 @@ static char *tagsel[][2] = {
{ col_tag7_text, col_tag7 },
{ col_tag8_text, col_tag8 },
{ col_tag9_text, col_tag9 },
/* Text Background */
/* foreground background */
};
/* Alpha for tags */

View file

@ -97,6 +97,22 @@ enum { SchemeBorderNorm,
SchemeLayout,
SchemeStatus,
SchemeSystray,
SchemePowerline1,
SchemePowerline2,
SchemePowerline3,
SchemePowerline4,
SchemePowerline5,
SchemePowerline6,
SchemePowerline7,
SchemePowerline8,
SchemePowerline9,
SchemePowerline10,
SchemePowerline11,
SchemePowerline12,
SchemePowerline13,
SchemePowerline14,
SchemePowerline15,
SchemePowerline16,
};
enum { NetSupported, NetWMName,
@ -778,6 +794,7 @@ static int restart = 0; /* which means we are definitely not restarting */
static Cur *cursor[CurLast];
static Clr **scheme;
static Clr **tagscheme;
static Clr **powerlinescheme;
static Display *dpy;
static Drw *drw;
static Monitor *mons, *selmon;
@ -1935,28 +1952,6 @@ dragcfact(const Arg *arg)
}
#endif
Bool
isHexDigit(char digit) {
return (digit >= '0' && digit <= '9') || (digit >= 'A' && digit <= 'F') || (digit >= 'a' && digit <= 'f');
}
Bool
isHexColor(char* hex) {
return isHexDigit(hex[1]) && isHexDigit(hex[2]) && isHexDigit(hex[3]) &&
isHexDigit(hex[4]) && isHexDigit(hex[5]) && isHexDigit(hex[6]) &&
hex[0] == '#' && hex[7] == '\0';
}
void
readAndSetColor(int clrIdx, char* txt) {
char buf[8];
memcpy(buf, txt, 7);
buf[7] = '\0';
if(isHexColor(buf)) {
drw_clr_create(drw, &drw->scheme[clrIdx], buf, alphas[SchemeStatus][ColBg]);
}
}
/* drag mfact with mouse */
#if USEMOUSE
void
@ -5161,6 +5156,9 @@ setup(void)
tagscheme = ecalloc(LENGTH(tagsel), sizeof(Clr *));
for (i = 0; i < LENGTH(tagsel); i++)
tagscheme[i] = drw_scm_create(drw, tagsel[i], tagalpha, 2);
powerlinescheme = ecalloc(LENGTH(powerlinecolors), sizeof(Clr *));
for (i = 0; i < LENGTH(powerlinecolors); i++)
powerlinescheme[i] = drw_scm_create(drw, powerlinecolors[i], alphas[i], 3);
/* init bars */
updatebars();
updatestatus();