dwm xrdb patch
This commit is contained in:
1 parent
0134ae84cb
commit
2e90480144
11 files changed
+321
-24
No files matched your search
@@ -5,3 +5,9 @@ xterm*Foreground: white
|
|||||||
xterm*faceName: JetBrainsMono Nerd Font Mono
|
xterm*faceName: JetBrainsMono Nerd Font Mono
|
||||||
xterm*faceSize: 14
|
xterm*faceSize: 14
|
||||||
|
|
||||||
|
dwm.normbordercolor: #444444
|
||||||
|
dwm.normbgcolor: #222222
|
||||||
|
dwm.normfgcolor: #bbbbbb
|
||||||
|
dwm.selbordercolor: #00ffff
|
||||||
|
dwm.selbgcolor: #000000
|
||||||
|
dwm.selfgcolor: #eeeeee
|
||||||
+24
-11
@@ -8,17 +8,28 @@ static const int showbar = 1; /* 0 means no bar */
|
|||||||
static const int topbar = 1; /* 0 means bottom bar */
|
static const int topbar = 1; /* 0 means bottom bar */
|
||||||
static const char *fonts[] = { "JetBrains Mono Nerd font:size=12" };
|
static const char *fonts[] = { "JetBrains Mono Nerd font:size=12" };
|
||||||
static const char dmenufont[] = "JetBrains Mono Nerd font:size=12";
|
static const char dmenufont[] = "JetBrains Mono Nerd font:size=12";
|
||||||
static const char col_gray1[] = "#222222";
|
static char normbgcolor[] = "#222222";
|
||||||
static const char col_gray2[] = "#444444";
|
static char normbordercolor[] = "#444444";
|
||||||
static const char col_gray3[] = "#bbbbbb";
|
static char normfgcolor[] = "#bbbbbb";
|
||||||
static const char col_gray4[] = "#eeeeee";
|
static char selfgcolor[] = "#eeeeee";
|
||||||
static const char col_cyan[] = "#00ffff";
|
static char selbordercolor[] = "#00ffff";
|
||||||
static const char color_black[] = "#000000";
|
static char selbgcolor[] = "#005577";
|
||||||
static const char *colors[][3] = {
|
static char *colors[][3] = {
|
||||||
/* fg bg border */
|
/* fg bg border */
|
||||||
[SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
|
[SchemeNorm] = { normfgcolor, normbgcolor, normbordercolor },
|
||||||
[SchemeSel] = { col_gray4, color_black, col_cyan },
|
[SchemeSel] = { selfgcolor, selbgcolor, selbordercolor },
|
||||||
};
|
};
|
||||||
|
// 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[] = "#00ffff";
|
||||||
|
// static const char color_black[] = "#000000";
|
||||||
|
// static const char *colors[][3] = {
|
||||||
|
// /* fg bg border */
|
||||||
|
// [SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
|
||||||
|
// [SchemeSel] = { col_gray4, color_black, col_cyan },
|
||||||
|
// };
|
||||||
|
|
||||||
/* tagging */
|
/* tagging */
|
||||||
static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
|
static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
|
||||||
@@ -61,7 +72,8 @@ static const Layout layouts[] = {
|
|||||||
|
|
||||||
//------------------------------------------------- dmenu -------------------------------------------------
|
//------------------------------------------------- dmenu -------------------------------------------------
|
||||||
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", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
|
||||||
|
static const char *dmenucmd[] = { "dmenu_run", "-fn", dmenufont, "-nb", normbgcolor, "-nf", normfgcolor, "-sb", selbordercolor, "-sf", selfgcolor, NULL };
|
||||||
//---------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
//-------------------------- applications ---------------------------------------------------------
|
//-------------------------- applications ---------------------------------------------------------
|
||||||
@@ -141,6 +153,7 @@ static const Key keys[] = {
|
|||||||
{ MODKEY|ShiftMask, XK_n, setgaps, {.i = 0 } },
|
{ MODKEY|ShiftMask, XK_n, setgaps, {.i = 0 } },
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
|
||||||
|
{ MODKEY, XK_F5, xrdb, {.v = NULL } },
|
||||||
{ MODKEY, XK_b, togglebar, {0} },
|
{ MODKEY, XK_b, togglebar, {0} },
|
||||||
{ MODKEY, XK_j, focusstack, {.i = +1 } },
|
{ MODKEY, XK_j, focusstack, {.i = +1 } },
|
||||||
{ MODKEY, XK_k, focusstack, {.i = -1 } },
|
{ MODKEY, XK_k, focusstack, {.i = -1 } },
|
||||||
|
|||||||
+24
-11
@@ -8,17 +8,28 @@ static const int showbar = 1; /* 0 means no bar */
|
|||||||
static const int topbar = 1; /* 0 means bottom bar */
|
static const int topbar = 1; /* 0 means bottom bar */
|
||||||
static const char *fonts[] = { "JetBrains Mono Nerd font:size=12" };
|
static const char *fonts[] = { "JetBrains Mono Nerd font:size=12" };
|
||||||
static const char dmenufont[] = "JetBrains Mono Nerd font:size=12";
|
static const char dmenufont[] = "JetBrains Mono Nerd font:size=12";
|
||||||
static const char col_gray1[] = "#222222";
|
static char normbgcolor[] = "#222222";
|
||||||
static const char col_gray2[] = "#444444";
|
static char normbordercolor[] = "#444444";
|
||||||
static const char col_gray3[] = "#bbbbbb";
|
static char normfgcolor[] = "#bbbbbb";
|
||||||
static const char col_gray4[] = "#eeeeee";
|
static char selfgcolor[] = "#eeeeee";
|
||||||
static const char col_cyan[] = "#00ffff";
|
static char selbordercolor[] = "#00ffff";
|
||||||
static const char color_black[] = "#000000";
|
static char selbgcolor[] = "#005577";
|
||||||
static const char *colors[][3] = {
|
static char *colors[][3] = {
|
||||||
/* fg bg border */
|
/* fg bg border */
|
||||||
[SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
|
[SchemeNorm] = { normfgcolor, normbgcolor, normbordercolor },
|
||||||
[SchemeSel] = { col_gray4, color_black, col_cyan },
|
[SchemeSel] = { selfgcolor, selbgcolor, selbordercolor },
|
||||||
};
|
};
|
||||||
|
// 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[] = "#00ffff";
|
||||||
|
// static const char color_black[] = "#000000";
|
||||||
|
// static const char *colors[][3] = {
|
||||||
|
// /* fg bg border */
|
||||||
|
// [SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
|
||||||
|
// [SchemeSel] = { col_gray4, color_black, col_cyan },
|
||||||
|
// };
|
||||||
|
|
||||||
/* tagging */
|
/* tagging */
|
||||||
static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
|
static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
|
||||||
@@ -61,7 +72,8 @@ static const Layout layouts[] = {
|
|||||||
|
|
||||||
//------------------------------------------------- dmenu -------------------------------------------------
|
//------------------------------------------------- dmenu -------------------------------------------------
|
||||||
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", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
|
||||||
|
static const char *dmenucmd[] = { "dmenu_run", "-fn", dmenufont, "-nb", normbgcolor, "-nf", normfgcolor, "-sb", selbordercolor, "-sf", selfgcolor, NULL };
|
||||||
//---------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
//-------------------------- applications ---------------------------------------------------------
|
//-------------------------- applications ---------------------------------------------------------
|
||||||
@@ -141,6 +153,7 @@ static const Key keys[] = {
|
|||||||
{ MODKEY|ShiftMask, XK_n, setgaps, {.i = 0 } },
|
{ MODKEY|ShiftMask, XK_n, setgaps, {.i = 0 } },
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
|
||||||
|
{ MODKEY, XK_F5, xrdb, {.v = NULL } },
|
||||||
{ MODKEY, XK_b, togglebar, {0} },
|
{ MODKEY, XK_b, togglebar, {0} },
|
||||||
{ MODKEY, XK_j, focusstack, {.i = +1 } },
|
{ MODKEY, XK_j, focusstack, {.i = +1 } },
|
||||||
{ MODKEY, XK_k, focusstack, {.i = -1 } },
|
{ MODKEY, XK_k, focusstack, {.i = -1 } },
|
||||||
|
|||||||
+1
-1
@@ -195,7 +195,7 @@ drw_clr_create(Drw *drw, Clr *dest, const char *clrname)
|
|||||||
/* Wrapper to create color schemes. The caller has to call free(3) on the
|
/* Wrapper to create color schemes. The caller has to call free(3) on the
|
||||||
* returned color scheme when done using it. */
|
* returned color scheme when done using it. */
|
||||||
Clr *
|
Clr *
|
||||||
drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount)
|
drw_scm_create(Drw *drw, char *clrnames[], size_t clrcount)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
Clr *ret;
|
Clr *ret;
|
||||||
|
|||||||
+1
-1
@@ -40,7 +40,7 @@ void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned in
|
|||||||
|
|
||||||
/* Colorscheme abstraction */
|
/* Colorscheme abstraction */
|
||||||
void drw_clr_create(Drw *drw, Clr *dest, const char *clrname);
|
void drw_clr_create(Drw *drw, Clr *dest, const char *clrname);
|
||||||
Clr *drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount);
|
Clr *drw_scm_create(Drw *drw, char *clrnames[], size_t clrcount);
|
||||||
|
|
||||||
/* Cursor abstraction */
|
/* Cursor abstraction */
|
||||||
Cur *drw_cur_create(Drw *drw, int shape);
|
Cur *drw_cur_create(Drw *drw, int shape);
|
||||||
|
|||||||
Binary file not shown.
BIN
Binary file not shown.
@@ -35,6 +35,7 @@
|
|||||||
#include <X11/Xatom.h>
|
#include <X11/Xatom.h>
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <X11/Xproto.h>
|
#include <X11/Xproto.h>
|
||||||
|
#include <X11/Xresource.h>
|
||||||
#include <X11/Xutil.h>
|
#include <X11/Xutil.h>
|
||||||
#ifdef XINERAMA
|
#ifdef XINERAMA
|
||||||
#include <X11/extensions/Xinerama.h>
|
#include <X11/extensions/Xinerama.h>
|
||||||
@@ -56,6 +57,21 @@
|
|||||||
#define HEIGHT(X) ((X)->h + 2 * (X)->bw)
|
#define HEIGHT(X) ((X)->h + 2 * (X)->bw)
|
||||||
#define TAGMASK ((1 << LENGTH(tags)) - 1)
|
#define TAGMASK ((1 << LENGTH(tags)) - 1)
|
||||||
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
|
#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'; \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
/* enums */
|
/* enums */
|
||||||
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
|
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
|
||||||
@@ -181,6 +197,7 @@ static void grabkeys(void);
|
|||||||
static void incnmaster(const Arg *arg);
|
static void incnmaster(const Arg *arg);
|
||||||
static void keypress(XEvent *e);
|
static void keypress(XEvent *e);
|
||||||
static void killclient(const Arg *arg);
|
static void killclient(const Arg *arg);
|
||||||
|
static void loadxrdb(void);
|
||||||
static void manage(Window w, XWindowAttributes *wa);
|
static void manage(Window w, XWindowAttributes *wa);
|
||||||
static void mappingnotify(XEvent *e);
|
static void mappingnotify(XEvent *e);
|
||||||
static void maprequest(XEvent *e);
|
static void maprequest(XEvent *e);
|
||||||
@@ -236,6 +253,7 @@ static Monitor *wintomon(Window w);
|
|||||||
static int xerror(Display *dpy, XErrorEvent *ee);
|
static int xerror(Display *dpy, XErrorEvent *ee);
|
||||||
static int xerrordummy(Display *dpy, XErrorEvent *ee);
|
static int xerrordummy(Display *dpy, XErrorEvent *ee);
|
||||||
static int xerrorstart(Display *dpy, XErrorEvent *ee);
|
static int xerrorstart(Display *dpy, XErrorEvent *ee);
|
||||||
|
static void xrdb(const Arg *arg);
|
||||||
static void zoom(const Arg *arg);
|
static void zoom(const Arg *arg);
|
||||||
|
|
||||||
/* variables */
|
/* variables */
|
||||||
@@ -1057,6 +1075,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
|
void
|
||||||
manage(Window w, XWindowAttributes *wa)
|
manage(Window w, XWindowAttributes *wa)
|
||||||
{
|
{
|
||||||
@@ -2226,6 +2275,17 @@ xerrorstart(Display *dpy, XErrorEvent *ee)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
xrdb(const Arg *arg)
|
||||||
|
{
|
||||||
|
loadxrdb();
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < LENGTH(colors); i++)
|
||||||
|
scheme[i] = drw_scm_create(drw, colors[i], 3);
|
||||||
|
focus(NULL);
|
||||||
|
arrange(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
zoom(const Arg *arg)
|
zoom(const Arg *arg)
|
||||||
{
|
{
|
||||||
@@ -2250,6 +2310,8 @@ main(int argc, char *argv[])
|
|||||||
if (!(dpy = XOpenDisplay(NULL)))
|
if (!(dpy = XOpenDisplay(NULL)))
|
||||||
die("dwm: cannot open display");
|
die("dwm: cannot open display");
|
||||||
checkotherwm();
|
checkotherwm();
|
||||||
|
XrmInitialize();
|
||||||
|
loadxrdb();
|
||||||
setup();
|
setup();
|
||||||
#ifdef __OpenBSD__
|
#ifdef __OpenBSD__
|
||||||
if (pledge("stdio rpath proc exec", NULL) == -1)
|
if (pledge("stdio rpath proc exec", NULL) == -1)
|
||||||
|
|||||||
Binary file not shown.
@@ -0,0 +1,203 @@
|
|||||||
|
From e7c65d2ce902a19a20daa751b42f8ba0209fdb61 Mon Sep 17 00:00:00 2001
|
||||||
|
From: NekoCWD <nekodevelopper@gmail.com>
|
||||||
|
Date: Sun, 22 Jan 2023 23:42:57 +0300
|
||||||
|
Subject: [PATCH] [dwm] xrdb update 6.4
|
||||||
|
|
||||||
|
---
|
||||||
|
config.def.h | 22 ++++++++++---------
|
||||||
|
drw.c | 2 +-
|
||||||
|
drw.h | 2 +-
|
||||||
|
dwm.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
4 files changed, 76 insertions(+), 12 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/config.def.h b/config.def.h
|
||||||
|
index 061ad66..686b947 100644
|
||||||
|
--- a/config.def.h
|
||||||
|
+++ b/config.def.h
|
||||||
|
@@ -7,15 +7,16 @@ static const int showbar = 1; /* 0 means no bar */
|
||||||
|
static const int topbar = 1; /* 0 means bottom bar */
|
||||||
|
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 const char *colors[][3] = {
|
||||||
|
- /* fg bg border */
|
||||||
|
- [SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
|
||||||
|
- [SchemeSel] = { col_gray4, col_cyan, col_cyan },
|
||||||
|
+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 },
|
||||||
|
};
|
||||||
|
|
||||||
|
/* tagging */
|
||||||
|
@@ -56,7 +57,7 @@ static const Layout layouts[] = {
|
||||||
|
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
|
||||||
|
|
||||||
|
/* commands */
|
||||||
|
-static const char *dmenucmd[] = { "dmenu_run", "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
|
||||||
|
+static const char *dmenucmd[] = { "dmenu_run", "-fn", dmenufont, "-nb", normbgcolor, "-nf", normfgcolor, "-sb", selbordercolor, "-sf", selfgcolor, NULL };
|
||||||
|
static const char *termcmd[] = { "st", NULL };
|
||||||
|
|
||||||
|
static const Key keys[] = {
|
||||||
|
@@ -84,6 +85,7 @@ static const 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)
|
||||||
|
diff --git a/drw.c b/drw.c
|
||||||
|
index a58a2b4..f8a82f5 100644
|
||||||
|
--- a/drw.c
|
||||||
|
+++ b/drw.c
|
||||||
|
@@ -195,7 +195,7 @@ drw_clr_create(Drw *drw, Clr *dest, const char *clrname)
|
||||||
|
/* 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[], size_t clrcount)
|
||||||
|
+drw_scm_create(Drw *drw, char *clrnames[], size_t clrcount)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
Clr *ret;
|
||||||
|
diff --git a/drw.h b/drw.h
|
||||||
|
index 6471431..bdbf950 100644
|
||||||
|
--- a/drw.h
|
||||||
|
+++ b/drw.h
|
||||||
|
@@ -40,7 +40,7 @@ void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned in
|
||||||
|
|
||||||
|
/* Colorscheme abstraction */
|
||||||
|
void drw_clr_create(Drw *drw, Clr *dest, const char *clrname);
|
||||||
|
-Clr *drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount);
|
||||||
|
+Clr *drw_scm_create(Drw *drw, char *clrnames[], size_t clrcount);
|
||||||
|
|
||||||
|
/* Cursor abstraction */
|
||||||
|
Cur *drw_cur_create(Drw *drw, int shape);
|
||||||
|
diff --git a/dwm.c b/dwm.c
|
||||||
|
index e5efb6a..3fe76be 100644
|
||||||
|
--- a/dwm.c
|
||||||
|
+++ b/dwm.c
|
||||||
|
@@ -35,6 +35,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>
|
||||||
|
@@ -56,6 +57,21 @@
|
||||||
|
#define HEIGHT(X) ((X)->h + 2 * (X)->bw)
|
||||||
|
#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'; \
|
||||||
|
+ } \
|
||||||
|
+ } \
|
||||||
|
+ }
|
||||||
|
|
||||||
|
/* enums */
|
||||||
|
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
|
||||||
|
@@ -178,6 +194,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);
|
||||||
|
@@ -233,6 +250,7 @@ static Monitor *wintomon(Window w);
|
||||||
|
static int xerror(Display *dpy, XErrorEvent *ee);
|
||||||
|
static int xerrordummy(Display *dpy, XErrorEvent *ee);
|
||||||
|
static int xerrorstart(Display *dpy, XErrorEvent *ee);
|
||||||
|
+static void xrdb(const Arg *arg);
|
||||||
|
static void zoom(const Arg *arg);
|
||||||
|
|
||||||
|
/* variables */
|
||||||
|
@@ -1019,6 +1037,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)
|
||||||
|
{
|
||||||
|
@@ -2110,6 +2159,17 @@ xerrorstart(Display *dpy, XErrorEvent *ee)
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
+void
|
||||||
|
+xrdb(const Arg *arg)
|
||||||
|
+{
|
||||||
|
+ loadxrdb();
|
||||||
|
+ int i;
|
||||||
|
+ for (i = 0; i < LENGTH(colors); i++)
|
||||||
|
+ scheme[i] = drw_scm_create(drw, colors[i], 3);
|
||||||
|
+ focus(NULL);
|
||||||
|
+ arrange(NULL);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
void
|
||||||
|
zoom(const Arg *arg)
|
||||||
|
{
|
||||||
|
@@ -2134,6 +2194,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)
|
||||||
|
--
|
||||||
|
2.38.2
|
||||||
|
|
||||||
Binary file not shown.
Reference in new issue
Block a user