Skip to content

fix(ml4w): stop Matugen from writing the colour files Dreamcoder owns - #20

Merged
Dreamcoder08 merged 1 commit into
mainfrom
fix/matugen-dreamcoder-outputs
Sep 29, 2026
Merged

Dreamcoder08 merged 1 commit into
mainfrom
fix/matugen-dreamcoder-outputs

Conversation

@Dreamcoder08

Copy link
Copy Markdown
Owner

After a dark to light switch on a live ML4W 2.16 machine, waybar/colors.css and hypr/colors.conf ended up as Matugen output even though the restore hook had run: restoring colours after Matugen is a race that can be lost.

Fix at the source. Disable the five Matugen templates whose output Dreamcoder owns (hyprland, hyprland-lua, waybar, rofi, swaync, the last one writing through a symlink into waybar/colors.css) in matugen/config.toml, with a reversible, idempotent #dreamcoder-off# marker. The result is validated as TOML before it is written; every other template keeps running. ML4W upgrades restore the stock file, so dreamcoder repair re-applies it. Verified live: a real dark to light toggle leaves all four files as Dreamcoder colours and verify-ml4w-setup.sh reports 23 passed / 0 failed.

Hardening of apply-ml4w-hooks.sh (raised by the GGA review, now running on gpt-6.1-sol):

  • every path embedded in the generated runner, listener and waypaper commands is shell-escaped with printf %q; the waypaper sed becomes awk + ENVIRON; the wallpaper variable name is validated
  • the Matugen config is left untouched when it cannot be validated as TOML
  • the listener hook and restart are skipped with a warning when timeout(1) is missing
  • a clear error when lib/env.sh is missing

Tests (bats 165+ all ok): a stock 2.16 Matugen fixture, idempotency, re-disable after an upgrade, and a hostile dots path (quotes, $(...), backticks, |, &, backslash) whose generated blocks are executed to prove nothing injected runs. The suite's isolation variables are now exported and guarded by a test: a run that reached the live config once left the real wallpaper runner pointing at a deleted temp path (repaired).

Matugen rewrites hypr/colors.conf, hypr/colors.lua, waybar/colors.css, rofi/colors.rasi and
(through a symlink into waybar) swaync/colors.css on every wallpaper or mode change. Restoring
the colours afterwards is a race that can be lost: after a dark to light switch the files
ended up as Matugen output even though the restore hook had run.

Disable those five template sections in matugen/config.toml with a reversible, idempotent
marker; other templates keep running. Also harden the script:
- leave the Matugen config untouched when it cannot be validated as TOML
- skip the listener hook and restart with a warning when timeout(1) is missing
- shell-escape (printf %q) every path embedded in the generated runner, listener and waypaper
  commands, replace the waypaper sed with awk + ENVIRON, and validate the wallpaper variable
  name; a test runs the generated blocks with a hostile path and checks nothing is executed
- fail with a clear message when lib/env.sh is missing

Tests use a stock 2.16 fixture, and the isolation variables are now exported plus guarded by a
test: a run that reached the live config once left the real wallpaper runner pointing at a
deleted temp path.
@Dreamcoder08
Dreamcoder08 merged commit fb42ccd into main Sep 29, 2026
13 checks passed
@Dreamcoder08
Dreamcoder08 deleted the fix/matugen-dreamcoder-outputs branch September 29, 2026 22:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant