1
0
mirror of https://github.com/alrayyes/dwm synced 2023-11-14 15:56:31 +00:00

feat: added xrdb patch to import wal colors

This commit is contained in:
Ryan Kes 2020-12-03 11:25:27 +01:00
parent 03d3f22aee
commit 24555deeea
3 changed files with 217 additions and 13 deletions

View File

@ -28,6 +28,7 @@ _patches=(
"local-allow-color-fonts.diff" "local-allow-color-fonts.diff"
"dwm-alpha-20201019-61bb8b2.diff" "dwm-alpha-20201019-61bb8b2.diff"
"dwm-statuscmd-signal-6.2.diff" "dwm-statuscmd-signal-6.2.diff"
"local-xrdb-6.2.diff"
) )
source=(http://dl.suckless.org/dwm/dwm-$pkgver.tar.gz source=(http://dl.suckless.org/dwm/dwm-$pkgver.tar.gz
@ -50,7 +51,8 @@ md5sums=('9929845ccdec4d2cc191f16210dd7f3d'
'b9c840237160440110fdafc204eff208' 'b9c840237160440110fdafc204eff208'
'cdf4c9dacfecd8f3aecb5fc8166c4604' 'cdf4c9dacfecd8f3aecb5fc8166c4604'
'7799f60a9e87e4f99e813d158abee15b' '7799f60a9e87e4f99e813d158abee15b'
'6343099cdc9752bc3f4f87e119345b79') '6343099cdc9752bc3f4f87e119345b79'
'62e3374566c0519000da48e2bec988d8')
prepare() { prepare() {
cd $srcdir/dwm-$pkgver cd $srcdir/dwm-$pkgver

View File

@ -14,22 +14,26 @@ static const char *fonts[] = {
"JoyPixels:pixelsize=10:antialias=true:autohint=true" "JoyPixels:pixelsize=10:antialias=true:autohint=true"
}; };
static const char dmenufont[] = "Hack Nerd Font Mono:size=10"; static const char dmenufont[] = "Hack Nerd Font Mono:size=10";
static const char col_gray1[] = "#222222";
static const char col_gray2[] = "#444444";
static const char col_gray3[] = "#bbbbbb";
static const char col_gray4[] = "#eeeeee";
static const char col_cyan[] = "#005577";
static const char col_black[] = "#000000"; static const char col_black[] = "#000000";
static const char col_red[] = "#ff0000"; static const char col_red[] = "#ff0000";
static const char col_yellow[] = "#ffff00"; static const char col_yellow[] = "#ffff00";
static const char col_white[] = "#ffffff"; static const char col_white[] = "#ffffff";
static const unsigned int baralpha = 0xd0;
static const unsigned int borderalpha = OPAQUE; static char normbgcolor[] = "#222222";
static const char *colors[][3] = { static char normbordercolor[] = "#444444";
/* fg bg border */ static char normfgcolor[] = "#bbbbbb";
[SchemeNorm] = { col_gray3, col_gray1, col_gray2 }, static char selfgcolor[] = "#eeeeee";
[SchemeSel] = { col_gray4, col_cyan, col_cyan }, static char selbordercolor[] = "#005577";
static char selbgcolor[] = "#005577";
static char *colors[][3] = {
/* fg bg border */
[SchemeNorm] = { normfgcolor, normbgcolor, normbordercolor },
[SchemeSel] = { selfgcolor, selbgcolor, selbordercolor },
}; };
//static const unsigned int baralpha = 0xd0;
static const unsigned int baralpha = 0xa0;
static const unsigned int borderalpha = OPAQUE;
static const unsigned int alphas[][3] = { static const unsigned int alphas[][3] = {
/* fg bg border */ /* fg bg border */
[SchemeNorm] = { OPAQUE, baralpha, borderalpha }, [SchemeNorm] = { OPAQUE, baralpha, borderalpha },
@ -93,7 +97,7 @@ static const Layout layouts[] = {
/* commands */ /* commands */
static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */ static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL }; static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", normbgcolor, "-nf", normfgcolor, "-sb", selbordercolor, "-sf", selfgcolor, NULL };
static const char *termcmd[] = { "st", NULL }; static const char *termcmd[] = { "st", NULL };
static const char scratchpadname[] = "scratchpad"; static const char scratchpadname[] = "scratchpad";
static const char *scratchpadcmd[] = { "st", "-t", scratchpadname, "-g", "120x34", NULL }; static const char *scratchpadcmd[] = { "st", "-t", scratchpadname, "-g", "120x34", NULL };
@ -131,6 +135,7 @@ static Key keys[] = {
{ MODKEY, XK_period, focusmon, {.i = +1 } }, { MODKEY, XK_period, focusmon, {.i = +1 } },
{ MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } }, { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
{ MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } }, { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
{ MODKEY, XK_x, xrdb, {.v = NULL } },
TAGKEYS( XK_1, 0) TAGKEYS( XK_1, 0)
TAGKEYS( XK_2, 1) TAGKEYS( XK_2, 1)
TAGKEYS( XK_3, 2) TAGKEYS( XK_3, 2)

197
local-xrdb-6.2.diff Normal file
View File

@ -0,0 +1,197 @@
diff -up -N a/config.def.h b/config.def.h
--- a/config.def.h 2020-12-03 09:59:28.269999652 +0100
+++ b/config.def.h 2020-12-03 10:13:49.821850315 +0100
@@ -10,18 +10,21 @@ static const int horizpadbar = 2;
static const int vertpadbar = 0; /* vertical padding for statusbar */
static const char *fonts[] = { "monospace:size=10" };
static const char dmenufont[] = "monospace:size=10";
-static const char col_gray1[] = "#222222";
-static const char col_gray2[] = "#444444";
-static const char col_gray3[] = "#bbbbbb";
-static const char col_gray4[] = "#eeeeee";
-static const char col_cyan[] = "#005577";
+
+static char normbgcolor[] = "#222222";
+static char normbordercolor[] = "#444444";
+static char normfgcolor[] = "#bbbbbb";
+static char selfgcolor[] = "#eeeeee";
+static char selbordercolor[] = "#005577";
+static char selbgcolor[] = "#005577";
+static char *colors[][3] = {
+ /* fg bg border */
+ [SchemeNorm] = { normfgcolor, normbgcolor, normbordercolor },
+ [SchemeSel] = { selfgcolor, selbgcolor, selbordercolor },
+};
+
static const unsigned int baralpha = 0xd0;
static const unsigned int borderalpha = OPAQUE;
-static const char *colors[][3] = {
- /* fg bg border */
- [SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
- [SchemeSel] = { col_gray4, col_cyan, col_cyan },
-};
static const unsigned int alphas[][3] = {
/* fg bg border */
[SchemeNorm] = { OPAQUE, baralpha, borderalpha },
@@ -69,7 +72,7 @@ static const Layout layouts[] = {
/* commands */
static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
-static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
+static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", normbgcolor, "-nf", normfgcolor, "-sb", selbordercolor, "-sf", selfgcolor, NULL };
static const char *termcmd[] = { "st", NULL };
static const char scratchpadname[] = "scratchpad";
static const char *scratchpadcmd[] = { "st", "-t", scratchpadname, "-g", "120x34", NULL };
@@ -107,6 +110,7 @@ static Key keys[] = {
{ MODKEY, XK_period, focusmon, {.i = +1 } },
{ MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
{ MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
+ { MODKEY, XK_F5, xrdb, {.v = NULL } },
TAGKEYS( XK_1, 0)
TAGKEYS( XK_2, 1)
TAGKEYS( XK_3, 2)
@@ -138,4 +142,3 @@ static Button buttons[] = {
{ ClkTagBar, MODKEY, Button1, tag, {0} },
{ ClkTagBar, MODKEY, Button3, toggletag, {0} },
};
-
diff -up -N a/drw.c b/drw.c
--- a/drw.c 2020-12-03 09:59:28.269999652 +0100
+++ b/drw.c 2020-12-03 10:10:50.065435009 +0100
@@ -198,7 +198,7 @@ drw_clr_create(Drw *drw, Clr *dest, cons
/* Wrapper to create color schemes. The caller has to call free(3) on the
* returned color scheme when done using it. */
Clr *
-drw_scm_create(Drw *drw, const char *clrnames[], const unsigned int alphas[], size_t clrcount)
+drw_scm_create(Drw *drw, char *clrnames[], const unsigned int alphas[], size_t clrcount)
{
size_t i;
Clr *ret;
diff -up -N a/drw.h b/drw.h
--- a/drw.h 2020-12-03 09:59:28.269999652 +0100
+++ b/drw.h 2020-12-03 10:03:50.930945343 +0100
@@ -42,7 +42,7 @@ void drw_font_getexts(Fnt *font, const c
/* Colorscheme abstraction */
void drw_clr_create(Drw *drw, Clr *dest, const char *clrname, unsigned int alpha);
-Clr *drw_scm_create(Drw *drw, const char *clrnames[], const unsigned int alphas[], size_t clrcount);
+Clr *drw_scm_create(Drw *drw, char *clrnames[], const unsigned int alphas[], size_t clrcount);
/* Cursor abstraction */
Cur *drw_cur_create(Drw *drw, int shape);
Binary files a/dwm and b/dwm differ
diff -up -N a/dwm.c b/dwm.c
--- a/dwm.c 2020-12-03 09:59:28.269999652 +0100
+++ b/dwm.c 2020-12-03 10:07:29.821925745 +0100
@@ -36,6 +36,7 @@
#include <X11/Xatom.h>
#include <X11/Xlib.h>
#include <X11/Xproto.h>
+#include <X11/Xresource.h>
#include <X11/Xutil.h>
#ifdef XINERAMA
#include <X11/extensions/Xinerama.h>
@@ -57,6 +58,21 @@
#define HEIGHT(X) ((X)->h + 2 * (X)->bw + gappx)
#define TAGMASK ((1 << LENGTH(tags)) - 1)
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
+#define XRDB_LOAD_COLOR(R,V) if (XrmGetResource(xrdb, R, NULL, &type, &value) == True) { \
+ 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 (i == 7) { \
+ strncpy(V, value.addr, 7); \
+ V[7] = '\0'; \
+ } \
+ } \
+ }
#define OPAQUE 0xffU
@@ -185,6 +201,7 @@ static void grabkeys(void);
static void incnmaster(const Arg *arg);
static void keypress(XEvent *e);
static void killclient(const Arg *arg);
+static void loadxrdb(void);
static void manage(Window w, XWindowAttributes *wa);
static void mappingnotify(XEvent *e);
static void maprequest(XEvent *e);
@@ -245,6 +262,7 @@ static int xerror(Display *dpy, XErrorEv
static int xerrordummy(Display *dpy, XErrorEvent *ee);
static int xerrorstart(Display *dpy, XErrorEvent *ee);
static void xinitvisual();
+static void xrdb(const Arg *arg);
static void zoom(const Arg *arg);
/* variables */
@@ -1128,6 +1146,37 @@ killclient(const Arg *arg)
}
void
+loadxrdb()
+{
+ Display *display;
+ char * resm;
+ XrmDatabase xrdb;
+ char *type;
+ XrmValue value;
+
+ display = XOpenDisplay(NULL);
+
+ if (display != NULL) {
+ resm = XResourceManagerString(display);
+
+ if (resm != NULL) {
+ xrdb = XrmGetStringDatabase(resm);
+
+ if (xrdb != NULL) {
+ XRDB_LOAD_COLOR("dwm.normbordercolor", normbordercolor);
+ XRDB_LOAD_COLOR("dwm.normbgcolor", normbgcolor);
+ XRDB_LOAD_COLOR("dwm.normfgcolor", normfgcolor);
+ XRDB_LOAD_COLOR("dwm.selbordercolor", selbordercolor);
+ XRDB_LOAD_COLOR("dwm.selbgcolor", selbgcolor);
+ XRDB_LOAD_COLOR("dwm.selfgcolor", selfgcolor);
+ }
+ }
+ }
+
+ XCloseDisplay(display);
+}
+
+void
manage(Window w, XWindowAttributes *wa)
{
Client *c, *t = NULL;
@@ -2454,6 +2503,17 @@ xinitvisual()
}
void
+xrdb(const Arg *arg)
+{
+ loadxrdb();
+ int i;
+ for (i = 0; i < LENGTH(colors); i++)
+ scheme[i] = drw_scm_create(drw, colors[i], alphas[i], 3);
+ focus(NULL);
+ arrange(NULL);
+}
+
+void
zoom(const Arg *arg)
{
Client *c = selmon->sel;
@@ -2479,6 +2539,8 @@ main(int argc, char *argv[])
if (!(dpy = XOpenDisplay(NULL)))
die("dwm: cannot open display");
checkotherwm();
+ XrmInitialize();
+ loadxrdb();
setup();
#ifdef __OpenBSD__
if (pledge("stdio rpath proc exec", NULL) == -1)
Binary files a/dwm.o and b/dwm.o differ