diff --git a/patches/recolr/README.md b/patches/recolr/README.md new file mode 100644 index 0000000..206b66d --- /dev/null +++ b/patches/recolr/README.md @@ -0,0 +1,11 @@ +### Description +this patch lets you change DWL colors without restart the session. +read the example colors file. + +### Download +- [Row file](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/recolr/recolr.patch) +- [0.7](/dwl/dwl-patches/raw/branch/main/patches/PATCHNAME/PATCHNAME.patch) +### Authors - latest at top [Codeberg nick is mandatory; other contact methods optional] + +- [codeberg](https://codeberg.org/pi66) +- [website](https://pi66.xyz) diff --git a/patches/recolr/example b/patches/recolr/example new file mode 100644 index 0000000..52b27cf --- /dev/null +++ b/patches/recolr/example @@ -0,0 +1,4 @@ +e5c9b8ff 131312ff 554e38ff +e5c9b8ff 954816ff 954816ff +131312ff 131312ff 131312ff + diff --git a/patches/recolr/recolr.patch b/patches/recolr/recolr.patch new file mode 100644 index 0000000..80c1f49 --- /dev/null +++ b/patches/recolr/recolr.patch @@ -0,0 +1,66 @@ +diff --git a/config.def.h b/config.def.h +index 95c2afa..73422ee 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -4,9 +4,12 @@ + ((hex >> 8) & 0xFF) / 255.0f, \ + (hex & 0xFF) / 255.0f } + /* appearance */ ++ + static const int sloppyfocus = 1; /* focus follows mouse */ + static const int bypass_surface_visibility = 0; /* 1 means idle inhibitors will disable idle tracking even if it's surface isn't visible */ + static const unsigned int borderpx = 1; /* border pixel of windows */ ++// Replace colors_dir with your own path, e.g /home/yourname/.cache/dwl-colors ++static const char *colors_dir = "/home/pixel/.cache/wal/dwl-colors"; + static const float rootcolor[] = COLOR(0x222222ff); + static const float bordercolor[] = COLOR(0x444444ff); + static const float focuscolor[] = COLOR(0x005577ff); +@@ -128,6 +131,7 @@ static const Key keys[] = { + { MODKEY, XKB_KEY_p, spawn, {.v = menucmd} }, + { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return, spawn, {.v = termcmd} }, + { MODKEY, XKB_KEY_j, focusstack, {.i = +1} }, ++ { MODKEY, XKB_KEY_n, reload_colors, {0} }, + { MODKEY, XKB_KEY_k, focusstack, {.i = -1} }, + { MODKEY, XKB_KEY_i, incnmaster, {.i = +1} }, + { MODKEY, XKB_KEY_d, incnmaster, {.i = -1} }, +diff --git a/dwl.c b/dwl.c +index 12f441e..0801673 100644 +--- a/dwl.c ++++ b/dwl.c +@@ -313,6 +313,7 @@ static void pointerfocus(Client *c, struct wlr_surface *surface, + static void printstatus(void); + static void powermgrsetmode(struct wl_listener *listener, void *data); + static void quit(const Arg *arg); ++static void reload_colors(const Arg *arg); + static void rendermon(struct wl_listener *listener, void *data); + static void requestdecorationmode(struct wl_listener *listener, void *data); + static void requeststartdrag(struct wl_listener *listener, void *data); +@@ -2146,6 +2147,28 @@ quit(const Arg *arg) + wl_display_terminate(dpy); + } + ++void ++reload_colors(const Arg *arg) ++{ ++ FILE *f = fopen(colors_dir, "r"); ++ if (!f) { ++ return; ++ } ++ ++ for (int i = 0; i < (int)LENGTH(colors); i++) { ++ unsigned int fg, bg, border; ++ if (fscanf(f, "%x %x %x", &fg, &bg, &border) != 3) { ++ break; ++ } ++ colors[i][ColFg] = fg; ++ colors[i][ColBg] = bg; ++ colors[i][ColBorder] = border; ++ } ++ ++ fclose(f); ++ drawbars(); ++} ++ + void + rendermon(struct wl_listener *listener, void *data) + {