Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend XRDB support to BAR_ALPHA patch #275

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config.def.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ static char selfloatbgcolor[] = "#117799";
#if BAR_ALPHA_PATCH
static const unsigned int baralpha = 0xd0;
static const unsigned int borderalpha = OPAQUE;
static const unsigned int alphas[][3] = {
static unsigned int alphas[][3] = {
/* fg bg border */
[SchemeNorm] = { OPAQUE, baralpha, borderalpha },
[SchemeSel] = { OPAQUE, baralpha, borderalpha },
Expand Down
138 changes: 138 additions & 0 deletions patch/xrdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,144 @@ loadxrdb()
xrdb = XrmGetStringDatabase(resm);

if (xrdb != NULL) {
#if BAR_ALPHA_PATCH
XRDB_LOAD_FLOAT("dwm.alphas.norm.fg", alphas[SchemeNorm][ColFg]);
XRDB_LOAD_FLOAT("dwm.alphas.norm.bg", alphas[SchemeNorm][ColBg]);
XRDB_LOAD_FLOAT("dwm.alphas.norm.border", alphas[SchemeNorm][ColBorder]);
XRDB_LOAD_FLOAT("dwm.alphas.sel.fg", alphas[SchemeSel][ColFg]);
XRDB_LOAD_FLOAT("dwm.alphas.sel.bg", alphas[SchemeSel][ColBg]);
XRDB_LOAD_FLOAT("dwm.alphas.sel.border", alphas[SchemeSel][ColBorder]);
XRDB_LOAD_FLOAT("dwm.alphas.titlenorm.fg", alphas[SchemeTitleNorm][ColFg]);
XRDB_LOAD_FLOAT("dwm.alphas.titlenorm.bg", alphas[SchemeTitleNorm][ColBg]);
XRDB_LOAD_FLOAT("dwm.alphas.titlenorm.border", alphas[SchemeTitleNorm][ColBorder]);
XRDB_LOAD_FLOAT("dwm.alphas.titlesel.fg", alphas[SchemeTitleSel][ColFg]);
XRDB_LOAD_FLOAT("dwm.alphas.titlesel.bg", alphas[SchemeTitleSel][ColBg]);
XRDB_LOAD_FLOAT("dwm.alphas.titlesel.border", alphas[SchemeTitleSel][ColBorder]);
XRDB_LOAD_FLOAT("dwm.alphas.tagsnorm.fg", alphas[SchemeTagsNorm][ColFg]);
XRDB_LOAD_FLOAT("dwm.alphas.tagsnorm.bg", alphas[SchemeTagsNorm][ColBg]);
XRDB_LOAD_FLOAT("dwm.alphas.tagsnorm.border", alphas[SchemeTagsNorm][ColBorder]);
XRDB_LOAD_FLOAT("dwm.alphas.tagssel.fg", alphas[SchemeTagsSel][ColFg]);
XRDB_LOAD_FLOAT("dwm.alphas.tagssel.bg", alphas[SchemeTagsSel][ColBg]);
XRDB_LOAD_FLOAT("dwm.alphas.tagssel.border", alphas[SchemeTagsSel][ColBorder]);
XRDB_LOAD_FLOAT("dwm.alphas.hidnorm.fg", alphas[SchemeHidNorm][ColFg]);
XRDB_LOAD_FLOAT("dwm.alphas.hidnorm.bg", alphas[SchemeHidNorm][ColBg]);
XRDB_LOAD_FLOAT("dwm.alphas.hidnorm.border", alphas[SchemeHidNorm][ColBorder]);
XRDB_LOAD_FLOAT("dwm.alphas.hidsel.fg", alphas[SchemeHidSel][ColFg]);
XRDB_LOAD_FLOAT("dwm.alphas.hidsel.bg", alphas[SchemeHidSel][ColBg]);
XRDB_LOAD_FLOAT("dwm.alphas.hidsel.border", alphas[SchemeHidSel][ColBorder]);
XRDB_LOAD_FLOAT("dwm.alphas.urg.fg", alphas[SchemeUrg][ColFg]);
XRDB_LOAD_FLOAT("dwm.alphas.urg.bg", alphas[SchemeUrg][ColBg]);
XRDB_LOAD_FLOAT("dwm.alphas.urg.border", alphas[SchemeUrg][ColBorder]);
#if RENAMED_SCRATCHPADS_PATCH
XRDB_LOAD_FLOAT("dwm.alphas.scratchsel.fg", alphas[SchemeScratchSel][ColFg]);
XRDB_LOAD_FLOAT("dwm.alphas.scratchsel.bg", alphas[SchemeScratchSel][ColBg]);
XRDB_LOAD_FLOAT("dwm.alphas.scratchsel.border", alphas[SchemeScratchSel][ColBorder]);
XRDB_LOAD_FLOAT("dwm.alphas.scratchnorm.fg", alphas[SchemeScratchNorm][ColFg]);
XRDB_LOAD_FLOAT("dwm.alphas.scratchnorm.bg", alphas[SchemeScratchNorm][ColBg]);
XRDB_LOAD_FLOAT("dwm.alphas.scratchnorm.border", alphas[SchemeScratchNorm][ColBorder]);
#endif // RENAMED_SCRATCHPADS_PATCH
#if BAR_FLEXWINTITLE_PATCH
XRDB_LOAD_FLOAT("dwm.alphas.flexactttb.fg", alphas[SchemeFlexActTTB][ColFg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexactttb.bg", alphas[SchemeFlexActTTB][ColBg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexactttb.border", alphas[SchemeFlexActTTB][ColBorder]);
XRDB_LOAD_FLOAT("dwm.alphas.flexactltr.fg", alphas[SchemeFlexActLTR][ColFg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexactltr.bg", alphas[SchemeFlexActLTR][ColBg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexactltr.border", alphas[SchemeFlexActLTR][ColBorder]);
XRDB_LOAD_FLOAT("dwm.alphas.flexactmono.fg", alphas[SchemeFlexActMONO][ColFg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexactmono.bg", alphas[SchemeFlexActMONO][ColBg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexactmono.border", alphas[SchemeFlexActMONO][ColBorder]);
XRDB_LOAD_FLOAT("dwm.alphas.flexactgrid.fg", alphas[SchemeFlexActGRID][ColFg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexactgrid.bg", alphas[SchemeFlexActGRID][ColBg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexactgrid.border", alphas[SchemeFlexActGRID][ColBorder]);
XRDB_LOAD_FLOAT("dwm.alphas.flexactgrd1.fg", alphas[SchemeFlexActGRD1][ColFg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexactgrd1.bg", alphas[SchemeFlexActGRD1][ColBg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexactgrd1.border", alphas[SchemeFlexActGRD1][ColBorder]);
XRDB_LOAD_FLOAT("dwm.alphas.flexactgrd2.fg", alphas[SchemeFlexActGRD2][ColFg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexactgrd2.bg", alphas[SchemeFlexActGRD2][ColBg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexactgrd2.border", alphas[SchemeFlexActGRD2][ColBorder]);
XRDB_LOAD_FLOAT("dwm.alphas.flexactgrdm.fg", alphas[SchemeFlexActGRDM][ColFg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexactgrdm.bg", alphas[SchemeFlexActGRDM][ColBg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexactgrdm.border", alphas[SchemeFlexActGRDM][ColBorder]);
XRDB_LOAD_FLOAT("dwm.alphas.flexacthgrd.fg", alphas[SchemeFlexActHGRD][ColFg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexacthgrd.bg", alphas[SchemeFlexActHGRD][ColBg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexacthgrd.border", alphas[SchemeFlexActHGRD][ColBorder]);
XRDB_LOAD_FLOAT("dwm.alphas.flexactdwdl.fg", alphas[SchemeFlexActDWDL][ColFg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexactdwdl.bg", alphas[SchemeFlexActDWDL][ColBg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexactdwdl.border", alphas[SchemeFlexActDWDL][ColBorder]);
XRDB_LOAD_FLOAT("dwm.alphas.flexactsprl.fg", alphas[SchemeFlexActSPRL][ColFg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexactsprl.bg", alphas[SchemeFlexActSPRL][ColBg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexactsprl.border", alphas[SchemeFlexActSPRL][ColBorder]);
XRDB_LOAD_FLOAT("dwm.alphas.flexactfloat.fg", alphas[SchemeFlexActFloat][ColFg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexactfloat.bg", alphas[SchemeFlexActFloat][ColBg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexactfloat.border", alphas[SchemeFlexActFloat][ColBorder]);
XRDB_LOAD_FLOAT("dwm.alphas.flexinattb.fg", alphas[SchemeFlexInaTTB][ColFg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexinattb.bg", alphas[SchemeFlexInaTTB][ColBg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexinattb.border", alphas[SchemeFlexInaTTB][ColBorder]);
XRDB_LOAD_FLOAT("dwm.alphas.flexinaltr.fg", alphas[SchemeFlexInaLTR][ColFg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexinaltr.bg", alphas[SchemeFlexInaLTR][ColBg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexinaltr.border", alphas[SchemeFlexInaLTR][ColBorder]);
XRDB_LOAD_FLOAT("dwm.alphas.flexinamono.fg", alphas[SchemeFlexInaMONO][ColFg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexinamono.bg", alphas[SchemeFlexInaMONO][ColBg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexinamono.border", alphas[SchemeFlexInaMONO][ColBorder]);
XRDB_LOAD_FLOAT("dwm.alphas.flexinagrid.fg", alphas[SchemeFlexInaGRID][ColFg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexinagrid.bg", alphas[SchemeFlexInaGRID][ColBg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexinagrid.border", alphas[SchemeFlexInaGRID][ColBorder]);
XRDB_LOAD_FLOAT("dwm.alphas.flexinagrd1.fg", alphas[SchemeFlexInaGRD1][ColFg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexinagrd1.bg", alphas[SchemeFlexInaGRD1][ColBg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexinagrd1.border", alphas[SchemeFlexInaGRD1][ColBorder]);
XRDB_LOAD_FLOAT("dwm.alphas.flexinagrd2.fg", alphas[SchemeFlexInaGRD2][ColFg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexinagrd2.bg", alphas[SchemeFlexInaGRD2][ColBg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexinagrd2.border", alphas[SchemeFlexInaGRD2][ColBorder]);
XRDB_LOAD_FLOAT("dwm.alphas.flexinagrdm.fg", alphas[SchemeFlexInaGRDM][ColFg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexinagrdm.bg", alphas[SchemeFlexInaGRDM][ColBg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexinagrdm.border", alphas[SchemeFlexInaGRDM][ColBorder]);
XRDB_LOAD_FLOAT("dwm.alphas.flexinahgrd.fg", alphas[SchemeFlexInaHGRD][ColFg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexinahgrd.bg", alphas[SchemeFlexInaHGRD][ColBg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexinahgrd.border", alphas[SchemeFlexInaHGRD][ColBorder]);
XRDB_LOAD_FLOAT("dwm.alphas.flexinadwdl.fg", alphas[SchemeFlexInaDWDL][ColFg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexinadwdl.bg", alphas[SchemeFlexInaDWDL][ColBg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexinadwdl.border", alphas[SchemeFlexInaDWDL][ColBorder]);
XRDB_LOAD_FLOAT("dwm.alphas.flexinasprl.fg", alphas[SchemeFlexInaSPRL][ColFg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexinasprl.bg", alphas[SchemeFlexInaSPRL][ColBg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexinasprl.border", alphas[SchemeFlexInaSPRL][ColBorder]);
XRDB_LOAD_FLOAT("dwm.alphas.flexinafloat.fg", alphas[SchemeFlexInaFloat][ColFg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexinafloat.bg", alphas[SchemeFlexInaFloat][ColBg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexinafloat.border", alphas[SchemeFlexInaFloat][ColBorder]);
XRDB_LOAD_FLOAT("dwm.alphas.flexselttb.fg", alphas[SchemeFlexSelTTB][ColFg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexselttb.bg", alphas[SchemeFlexSelTTB][ColBg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexselttb.border", alphas[SchemeFlexSelTTB][ColBorder]);
XRDB_LOAD_FLOAT("dwm.alphas.flexselltr.fg", alphas[SchemeFlexSelLTR][ColFg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexselltr.bg", alphas[SchemeFlexSelLTR][ColBg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexselltr.border", alphas[SchemeFlexSelLTR][ColBorder]);
XRDB_LOAD_FLOAT("dwm.alphas.flexselmono.fg", alphas[SchemeFlexSelMONO][ColFg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexselmono.bg", alphas[SchemeFlexSelMONO][ColBg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexselmono.border", alphas[SchemeFlexSelMONO][ColBorder]);
XRDB_LOAD_FLOAT("dwm.alphas.flexselgrid.fg", alphas[SchemeFlexSelGRID][ColFg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexselgrid.bg", alphas[SchemeFlexSelGRID][ColBg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexselgrid.border", alphas[SchemeFlexSelGRID][ColBorder]);
XRDB_LOAD_FLOAT("dwm.alphas.flexselgrd1.fg", alphas[SchemeFlexSelGRD1][ColFg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexselgrd1.bg", alphas[SchemeFlexSelGRD1][ColBg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexselgrd1.border", alphas[SchemeFlexSelGRD1][ColBorder]);
XRDB_LOAD_FLOAT("dwm.alphas.flexselgrd2.fg", alphas[SchemeFlexSelGRD2][ColFg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexselgrd2.bg", alphas[SchemeFlexSelGRD2][ColBg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexselgrd2.border", alphas[SchemeFlexSelGRD2][ColBorder]);
XRDB_LOAD_FLOAT("dwm.alphas.flexselgrdm.fg", alphas[SchemeFlexSelGRDM][ColFg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexselgrdm.bg", alphas[SchemeFlexSelGRDM][ColBg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexselgrdm.border", alphas[SchemeFlexSelGRDM][ColBorder]);
XRDB_LOAD_FLOAT("dwm.alphas.flexselhgrd.fg", alphas[SchemeFlexSelHGRD][ColFg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexselhgrd.bg", alphas[SchemeFlexSelHGRD][ColBg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexselhgrd.border", alphas[SchemeFlexSelHGRD][ColBorder]);
XRDB_LOAD_FLOAT("dwm.alphas.flexseldwdl.fg", alphas[SchemeFlexSelDWDL][ColFg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexseldwdl.bg", alphas[SchemeFlexSelDWDL][ColBg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexseldwdl.border", alphas[SchemeFlexSelDWDL][ColBorder]);
XRDB_LOAD_FLOAT("dwm.alphas.flexselsprl.fg", alphas[SchemeFlexSelSPRL][ColFg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexselsprl.bg", alphas[SchemeFlexSelSPRL][ColBg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexselsprl.border", alphas[SchemeFlexSelSPRL][ColBorder]);
XRDB_LOAD_FLOAT("dwm.alphas.flexselfloat.fg", alphas[SchemeFlexSelFloat][ColFg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexselfloat.bg", alphas[SchemeFlexSelFloat][ColBg]);
XRDB_LOAD_FLOAT("dwm.alphas.flexselfloat.border", alphas[SchemeFlexSelFloat][ColBorder]);
#endif // BAR_FLEXWINTITLE_PATCH
#endif // BAR_ALPHA_PATCH
XRDB_LOAD_COLOR("dwm.normfgcolor", normfgcolor);
XRDB_LOAD_COLOR("dwm.normbgcolor", normbgcolor);
XRDB_LOAD_COLOR("dwm.normbordercolor", normbordercolor);
Expand Down
15 changes: 11 additions & 4 deletions patch/xrdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
if (value.addr != NULL && strnlen(value.addr, 8) == 7 && value.addr[0] == '#') { \
int i = 1; \
for (; i <= 6; i++) { \
if (value.addr[i] < 48) break; \
if (value.addr[i] > 57 && value.addr[i] < 65) break; \
if (value.addr[i] > 70 && value.addr[i] < 97) break; \
if (value.addr[i] > 102) break; \
if (value.addr[i] < '0') break; \
if (value.addr[i] > '9' && value.addr[i] < 'A') break; \
if (value.addr[i] > 'F' && value.addr[i] < 'a') break; \
if (value.addr[i] > 'f') break; \
} \
if (i == 7) { \
strncpy(V, value.addr, 7); \
Expand All @@ -16,6 +16,13 @@
} \
}

#if BAR_ALPHA_PATCH
#define XRDB_LOAD_FLOAT(R,V) if (XrmGetResource(xrdb, R, NULL, &type, &value) == True) { \
if (value.addr) \
V = strtof(value.addr, NULL) * OPAQUE; \
}
#endif // BAR_ALPHA_PATCH

static void loadxrdb(void);
static void xrdb(const Arg *arg);

Expand Down