diff --git a/config.h b/config.h index 04dc77c..beb4c11 100644 --- a/config.h +++ b/config.h @@ -240,14 +240,14 @@ static Key keys[] = { { MODKEY, XK_F2, spawn, {.v = (const char*[]){ "tutorialvids", NULL } } }, { MODKEY, XK_F3, spawn, {.v = (const char*[]){ "displayselect", NULL } } }, { MODKEY, XK_F4, spawn, SHCMD(TERMINAL " -e pulsemixer; kill -44 $(pidof dwmblocks)") }, - /* { MODKEY, XK_F5, xrdb, {.v = NULL } }, */ + { MODKEY, XK_F5, xrdb, {.v = NULL } }, { MODKEY, XK_F6, spawn, {.v = (const char*[]){ "torwrap", NULL } } }, { MODKEY, XK_F7, spawn, {.v = (const char*[]){ "td-toggle", NULL } } }, { MODKEY, XK_F8, spawn, {.v = (const char*[]){ "mw", "-Y", NULL } } }, { MODKEY, XK_F9, spawn, {.v = (const char*[]){ "dmenumount", NULL } } }, { MODKEY, XK_F10, spawn, {.v = (const char*[]){ "dmenuumount", NULL } } }, { MODKEY, XK_F11, spawn, SHCMD("mpv --untimed --no-cache --no-osc --no-input-default-bindings --profile=low-latency --input-conf=/dev/null --title=webcam $(ls /dev/video[0,2,4,6,8] | tail -n 1)") }, - { MODKEY, XK_F12, spawn, SHCMD("remaps & notify-send \"⌨️ Keyboard remapping...\" \"Re-running keyboard defaults for any newly plugged-in keyboards.\"") }, + { MODKEY, XK_F12, spawn, SHCMD("remaps") }, { MODKEY, XK_space, zoom, {0} }, { MODKEY|ShiftMask, XK_space, togglefloating, {0} }, @@ -270,7 +270,7 @@ static Key keys[] = { { 0, XF86XK_AudioForward, spawn, {.v = (const char*[]){ "mpc", "seek", "+10", NULL } } }, { 0, XF86XK_AudioMedia, spawn, {.v = (const char*[]){ TERMINAL, "-e", "ncmpcpp", NULL } } }, { 0, XF86XK_AudioMicMute, spawn, SHCMD("pactl set-source-mute @DEFAULT_SOURCE@ toggle") }, - { 0, XF86XK_PowerOff, spawn, {.v = (const char*[]){ "sysact", NULL } } }, + /* { 0, XF86XK_PowerOff, spawn, {.v = (const char*[]){ "sysact", NULL } } }, */ { 0, XF86XK_Calculator, spawn, {.v = (const char*[]){ TERMINAL, "-e", "bc", "-l", NULL } } }, { 0, XF86XK_Sleep, spawn, {.v = (const char*[]){ "sudo", "-A", "zzz", NULL } } }, { 0, XF86XK_WWW, spawn, {.v = (const char*[]){ BROWSER, NULL } } }, @@ -332,3 +332,4 @@ static Button buttons[] = { { ClkTagBar, 0, Button5, shiftview, {.i = 1} }, { ClkRootWin, 0, Button2, togglebar, {0} }, }; + diff --git a/dwm.c b/dwm.c index c0d141d..4f3faff 100644 --- a/dwm.c +++ b/dwm.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #ifdef XINERAMA @@ -67,6 +68,21 @@ #define SPTAG(i) ((1 << LENGTH(tags)) << (i)) #define SPTAGMASK (((1 << LENGTH(scratchpads))-1) << LENGTH(tags)) #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 TRUNC(X,A,B) (MAX((A), MIN((X), (B)))) /* enums */ @@ -212,6 +228,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); @@ -278,6 +295,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); static void load_xresources(void); static void resource_load(XrmDatabase db, char *name, enum resource_type rtype, void *dst); @@ -1190,6 +1208,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.color0", normbordercolor); + XRDB_LOAD_COLOR("dwm.color0", normbgcolor); + XRDB_LOAD_COLOR("dwm.color4", normfgcolor); + XRDB_LOAD_COLOR("dwm.color8", selbordercolor); + XRDB_LOAD_COLOR("dwm.color4", selbgcolor); + XRDB_LOAD_COLOR("dwm.color0", selfgcolor); + } + } + } + + XCloseDisplay(display); +} + void manage(Window w, XWindowAttributes *wa) { @@ -2530,6 +2579,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) { @@ -2627,3 +2687,4 @@ main(int argc, char *argv[]) XCloseDisplay(dpy); return EXIT_SUCCESS; } +