diff --git a/hosts/perseus/overlays.nix b/hosts/perseus/overlays.nix index 74bf5a4..88bd03a 100644 --- a/hosts/perseus/overlays.nix +++ b/hosts/perseus/overlays.nix @@ -1,11 +1,15 @@ [ (final: prev: { - dwl = ( - prev.dwl.override { + dwl = + (prev.dwl.override { configH = ./config_files/dwl/config.h; enableXWayland = true; - } - ); + }).overrideAttrs + (oldAttrs: { + patches = oldAttrs.patches or [ ] ++ [ + ../../patches/dwl/refresh_rate.patch + ]; + }); }) (final: prev: { diff --git a/patches/dwl/refresh_rate.patch b/patches/dwl/refresh_rate.patch new file mode 100644 index 0000000..4d2ee95 --- /dev/null +++ b/patches/dwl/refresh_rate.patch @@ -0,0 +1,31 @@ +--- dwl-bak/dwl.c 2026-04-09 15:53:00.841862418 +0200 ++++ dwl/dwl.c 2026-04-09 16:02:39.604999328 +0200 +@@ -1045,6 +1045,7 @@ + size_t i; + struct wlr_output_state state; + Monitor *m; ++ struct wlr_output_mode *mode = NULL; + + if (!wlr_output_init_render(wlr_output, alloc, drw)) + return; +@@ -1077,7 +1078,19 @@ + * monitor supports only a specific set of modes. We just pick the + * monitor's preferred mode; a more sophisticated compositor would let + * the user configure it. */ +- wlr_output_state_set_mode(&state, wlr_output_preferred_mode(wlr_output)); ++ if (refresh_rate || s_width || s_height) { ++ wl_list_for_each(mode, &wlr_output->modes, link) { ++ if ((refresh_rate == 0 || mode->refresh == refresh_rate) && (s_width == 0 || mode->width == s_width) && (s_height == 0 || mode->height == s_height)) { ++ break; ++ } ++ } ++ } ++ if (mode == NULL) { ++ printf("Was not able find output mode with (width, height, refresh rate): (%d, %d, %d)\n", s_width, s_height, refresh_rate); ++ mode = wlr_output_preferred_mode(wlr_output); ++ } ++ ++ wlr_output_state_set_mode(&state, mode); + + /* Set up event listeners */ + LISTEN(&wlr_output->events.frame, &m->frame, rendermon);