From 9ca0c8c715efe048da3d835685dc643f894e4c57 Mon Sep 17 00:00:00 2001 From: Luca Bilke Date: Thu, 9 Feb 2023 19:54:58 +0100 Subject: [PATCH] remove xresources patch --- README.md | 4 +++ config.h | 94 +++++++++++++------------------------------------------ drw.c | 2 +- drw.h | 2 +- dwm.c | 70 +---------------------------------------- 5 files changed, 28 insertions(+), 144 deletions(-) diff --git a/README.md b/README.md index f5acca0..bb579a9 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,10 @@ Mod|w|Spawn Ferdium # System Modifier(s)|Key|Action :--|:--|:-- +Mod|i|Close the topmost notification +Mod Shift|i|Bring back the last closed notification +Mod|d|Open the context menu for the topmost notification +Mod Shift|d|Run the default action for the topmost notification Mod|F3|Spawn volume panel Mod|F9|Spawn mounting menu Mod|F10|Spawn unmounting menu diff --git a/config.h b/config.h index aeaa15a..5004451 100644 --- a/config.h +++ b/config.h @@ -20,55 +20,25 @@ static const char *fonts[] = { "monospace:pixelsize=30", }; -static char color0[] = "#000000"; -static char color1[] = "#7f0000"; -static char color2[] = "#007f00"; -static char color3[] = "#7f7f00"; -static char color4[] = "#00007f"; -static char color5[] = "#7f007f"; -static char color6[] = "#007f7f"; -static char color7[] = "#cccccc"; -static char color8[] = "#333333"; -static char color9[] = "#ff0000"; -static char color10[] = "#00ff00"; -static char color11[] = "#ffff00"; -static char color12[] = "#0000ff"; -static char color13[] = "#ff00ff"; -static char color14[] = "#00ffff"; -static char color15[] = "#ffffff"; -static char bordernorm[] = "#222222"; -static char bordersel[] = "#444444"; - -static char *barschemes[][3] = { - /* fg bg border */ - [SchemeNorm] = { color15, color0, bordernorm }, - [SchemeSel] = { color15, color4, bordersel }, - [SchemeStatus] = { color7, color0, "#000000" }, // Statusbar right - [SchemeTagsSel] = { color0, color4, "#000000" }, // Tagbar left selected - [SchemeTagsNorm] = { color7, color0, "#000000" }, // Tagbar left unselected - [SchemeInfoSel] = { color7, color0, "#000000" }, // infobar middle selected - [SchemeInfoNorm] = { color7, color0, "#000000" }, // infobar middle unselected +static const char colors[][7] = { + [0] = "#15161E", [1] = "#f7768e", [2] = "#9ece6a", [3] = "#e0af68", + [4] = "#7aa2f7", [5] = "#bb9af7", [6] = "#7dcfff", [7] = "#a9b1d6", + [8] = "#414868", [9] = "#f7768e", [10] = "#9ece6a", [11] = "#e0af68", + [12] = "#7aa2f7", [13] = "#bb9af7", [14] = "#7dcfff", [15] = "#c0caf5", + /* Extra Colors (not accessible with SGR escapes) */ + [16] = "#383c4a", [17] = "#7aa2f7", }; -// static const char *colors[] = { -// [0] = "#000000", [1] = "#7f0000", [2] = "#007f00", [3] = "#7f7f00", -// [4] = "#00007f", [5] = "#7f007f", [6] = "#007f7f", [7] = "#cccccc", -// [8] = "#333333", [9] = "#ff0000", [10] = "#00ff00", [11] = "#ffff00", -// [12] = "#0000ff", [13] = "#ff00ff", [14] = "#00ffff", [15] = "#ffffff", -// /* Extra Colors (not accessible with SGR escapes) */ -// [16] = "#222222", [17] = "#444444", -// }; -// -// static char *barschemes[][3] = { -// /* fg bg border */ -// [SchemeNorm] = {colors[15], colors[0], colors[16]}, -// [SchemeSel] = {colors[15], colors[4], colors[17]}, -// [SchemeStatus] = {colors[7], colors[0], "#000000"}, // Statusbar right -// [SchemeTagsSel] = {colors[0], colors[4], "#000000"}, // Tagbar left selected -// [SchemeTagsNorm] = {colors[7], colors[0], "#000000"}, // Tagbar left unselected -// [SchemeInfoSel] = {colors[7], colors[0], "#000000"}, // infobar middle selected -// [SchemeInfoNorm] = {colors[7], colors[0], "#000000"}, // infobar middle unselected -// }; +static const char *barschemes[7][3] = { + /* fg bg border */ + [SchemeNorm] = {colors[15], colors[0], colors[16]}, + [SchemeSel] = {colors[15], colors[4], colors[17]}, + [SchemeStatus] = {colors[7], colors[0], "#000000"}, // Statusbar right + [SchemeTagsSel] = {colors[0], colors[4], "#000000"}, // Tagbar left selected + [SchemeTagsNorm] = {colors[7], colors[0], "#000000"}, // Tagbar left unselected + [SchemeInfoSel] = {colors[7], colors[0], "#000000"}, // infobar middle selected + [SchemeInfoNorm] = {colors[7], colors[0], "#000000"}, // infobar middle unselected +}; /* tagging */ static const char *tags[] = {"1", "2", "3", "4", "5", "6", "7", "8", "9"}; @@ -128,28 +98,6 @@ static const char *sphtop[] = { "h", TERMINAL, "--name", "sphtop", "-e", "htop", static const char *spmix[] = { "m", TERMINAL "--name", "spmix", "-e", "pulsemixer" }; static const char *sphelp[] = { "n", TERMINAL, "--name", "sphelp", "-e", "/bin/sh", "-c", "lowdown -Tterm /usr/local/share/dwm/dwm.md | less" }; -/* Xresources preferences to load at startup */ -ResourcePref resources[] = { - { "color0", STRING, &color0 }, - { "color1", STRING, &color1 }, - { "color2", STRING, &color2 }, - { "color3", STRING, &color3 }, - { "color4", STRING, &color4 }, - { "color5", STRING, &color5 }, - { "color6", STRING, &color6 }, - { "color7", STRING, &color7 }, - { "color8", STRING, &color8 }, - { "color9", STRING, &color9 }, - { "color10", STRING, &color10 }, - { "color11", STRING, &color11 }, - { "color12", STRING, &color12 }, - { "color13", STRING, &color13 }, - { "color14", STRING, &color14 }, - { "color15", STRING, &color15 }, - { "bordernorm", STRING, &bordernorm }, - { "bordersel", STRING, &bordersel }, -}; - #include static const Key keys[] = { @@ -219,10 +167,10 @@ static const Key keys[] = { { MODKEY | ShiftMask, XK_e, spawn, SHCMD(TERMINAL "-e $SHELL -c \"lf; $SHELL\"")}, { MODKEY, XK_u, spawn, {.v = (const char *[]){"dmenu_run", NULL}} }, // { MODKEY | ShiftMask, XK_u, spawn, {.v = (const char *[]){NULL}} }, - // { MODKEY, XK_i, spawn, {.v = (const char *[]){NULL}} }, - // { MODKEY | ShiftMask, XK_i, spawn, {.v = (const char *[]){NULL}} }, - // { MODKEY, XK_d, spawn, {.v = (const char *[]){NULL}} }, - // { MODKEY | ShiftMask, XK_d, spawn, {.v = (const char *[]){NULL}} }, + { MODKEY, XK_i, spawn, {.v = (const char *[]){"dunstctl", "close", NULL}} }, + { MODKEY | ShiftMask, XK_i, spawn, {.v = (const char *[]){"dunstctl", "history-pop", NULL}} }, + { MODKEY, XK_d, spawn, {.v = (const char *[]){"dunstctl", "context", NULL}} }, + { MODKEY | ShiftMask, XK_d, spawn, {.v = (const char *[]){"dunstctl", "action", "0", NULL}} }, { MODKEY, XK_h, setmfact, {.f = -0.05} }, // { MODKEY | ShiftMask, XK_h, spawn, {.v = (const char *[]){NULL}} }, { MODKEY, XK_t, spawn, {.v = (const char *[]){BROWSER, NULL}} }, diff --git a/drw.c b/drw.c index 992b70b..8e4cefb 100644 --- a/drw.c +++ b/drw.c @@ -173,7 +173,7 @@ void 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, char *clrnames[], size_t clrcount) { +Clr *drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount) { size_t i; Clr *ret; diff --git a/drw.h b/drw.h index bdbf950..6471431 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, char *clrnames[], size_t clrcount); +Clr *drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount); /* Cursor abstraction */ Cur *drw_cur_create(Drw *drw, int shape); diff --git a/dwm.c b/dwm.c index 4bfc15a..b6b92f2 100644 --- a/dwm.c +++ b/dwm.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include @@ -217,15 +216,6 @@ struct Systray { Client *icons; }; -/* Xresources preferences */ -enum resource_type { STRING = 0, INTEGER = 1, FLOAT = 2 }; - -typedef struct { - char *name; - enum resource_type type; - void *dst; -} ResourcePref; - /* function declarations */ static void applyrules(Client *c); static void applyfloatrules(Client *c, const Rule *r); @@ -343,8 +333,6 @@ static int xerror(Display *dpy, XErrorEvent *ee); static int xerrordummy(Display *dpy, XErrorEvent *ee); static int xerrorstart(Display *dpy, XErrorEvent *ee); 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); static pid_t getparentprocess(pid_t p); static int isdescprocess(pid_t p, pid_t c); @@ -402,11 +390,6 @@ struct Pertag { int showbars[LENGTH(tags) + 1]; /* display bar for the current tag */ }; -static char *colors[] = { - color0, color1, color2, color3, color4, color5, color6, color7, - color8, color9, color10, color11, color12, color13, color14, color15, -}; - /* compile-time check if all tags fit into an unsigned int bit array. */ struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; @@ -2331,7 +2314,7 @@ void setup(void) { barclrs = ecalloc(LENGTH(colors), sizeof(Clr)); - for (i = 0; i < LENGTH(colors); i++) + for (i = 0; i < 16; i++) drw_clr_create(drw, &barclrs[i], colors[i]); /* init system tray */ @@ -3253,55 +3236,6 @@ void zoom(const Arg *arg) { pop(c); } -void resource_load(XrmDatabase db, char *name, enum resource_type rtype, void *dst) { - char *sdst = NULL; - int *idst = NULL; - float *fdst = NULL; - - sdst = dst; - idst = dst; - fdst = dst; - - char fullname[256]; - char *type; - XrmValue ret; - - snprintf(fullname, sizeof(fullname), "%s.%s", "dwm", name); - fullname[sizeof(fullname) - 1] = '\0'; - - XrmGetResource(db, fullname, "*", &type, &ret); - if (!(ret.addr == NULL || strncmp("String", type, 64))) { - switch (rtype) { - case STRING: - strcpy(sdst, ret.addr); - break; - case INTEGER: - *idst = strtoul(ret.addr, NULL, 10); - break; - case FLOAT: - *fdst = strtof(ret.addr, NULL); - break; - } - } -} - -void load_xresources(void) { - Display *display; - char *resm; - XrmDatabase db; - ResourcePref *p; - - display = XOpenDisplay(NULL); - resm = XResourceManagerString(display); - if (!resm) - return; - - db = XrmGetStringDatabase(resm); - for (p = resources; p < resources + LENGTH(resources); p++) - resource_load(db, p->name, p->type, p->dst); - XCloseDisplay(display); -} - int main(int argc, char *argv[]) { if (argc == 2 && !strcmp("-v", argv[1])) die("dwm-" VERSION); @@ -3314,8 +3248,6 @@ int main(int argc, char *argv[]) { if (!(xcon = XGetXCBConnection(dpy))) die("dwm: cannot get xcb connection\n"); checkotherwm(); - XrmInitialize(); - load_xresources(); setup(); #ifdef __OpenBSD__ if (pledge("stdio rpath proc exec ps", NULL) == -1)