feat: optional matugen support as alternative dcol backend - #1735
feat: optional matugen support as alternative dcol backend#17350xGeN02 wants to merge 10 commits into
Conversation
Add wallbash-matugen.sh as a drop-in alternative to wallbash.sh for color extraction. Uses Material You tonal palettes from matugen instead of imagemagick k-means clustering. This provides a safety net for systems where imagemagick fails to extract colors. Configuration via DCOL_BACKEND env var: - imagemagick (default): original behavior, no change - matugen: use matugen exclusively - auto: try imagemagick first, fallback to matugen on failure Closes HyDE-Project#1701
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds an optional Material You backend: a new ChangesWallpaper Color Extraction Backend Abstraction
Sequence Diagram(s)sequenceDiagram
participant Cache as Wallpaper Cache (fn_wallcache)
participant Gen as fn_generate_dcol
participant WB as wallbash.sh
participant MatuScript as wallbash-matugen.sh
participant Mat as matugen
participant FS as Filesystem
Cache->>Gen: request .dcol for image
Gen->>WB: invoke wallbash.sh to produce .dcol
WB-->>Gen: .dcol created
Gen->>FS: check .mcol (exists & valid?)
alt .mcol missing/invalid and matugen available
Gen->>MatuScript: invoke wallbash-matugen.sh with image
MatuScript->>Mat: matugen image --json ...
Mat-->>MatuScript: tonal JSON
MatuScript->>MatuScript: python -> convert JSON to .mcol/.dcol lines
MatuScript-->>Gen: .mcol written
end
Gen-->>Cache: return .dcol path (and .mcol if produced)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Note on color differences between backendsImageMagick and matugen produce different colors from the same wallpaper — this is by design: ImageMagick (wallbash.sh)
Matugen (wallbash-matugen.sh)
Example (same wallpaper):Matugen is not meant to replicate imagemagick's output — it's an alternative approach that guarantees valid color extraction on systems where imagemagick's kmeans fails, while producing aesthetically coherent palettes. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
Configs/.local/lib/hyde/wallbash-matugen.sh (1)
67-76: ⚡ Quick winUpdate the mapping/tone comments to match the implemented logic.
This comment block contradicts the actual mapping in Line 90 and tone selection in Lines 95–105. Please align the documentation with the real behavior to avoid accidental regressions during future edits.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@Configs/.local/lib/hyde/wallbash-matugen.sh` around lines 67 - 76, The comment block describing the color mapping/tone rules is out of sync with the actual implementation; update the comment so it matches the real behavior used in the dcol assignment block and the tone selection logic (the code that builds pry, txt and xa1–xa9 for each dcol group). Specifically, read the implemented dcol grouping and the tone selection code that assigns pry/txt/xa1..xa9, then rewrite the header comments to reflect the correct mapping of group numbers to palettes and the true tone numbers/direction used for pry and txt (and the xa1–xa9 ordering) so the documentation mirrors the code.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@Configs/.local/lib/hyde/wallbash-matugen.sh`:
- Around line 67-76: The comment block describing the color mapping/tone rules
is out of sync with the actual implementation; update the comment so it matches
the real behavior used in the dcol assignment block and the tone selection logic
(the code that builds pry, txt and xa1–xa9 for each dcol group). Specifically,
read the implemented dcol grouping and the tone selection code that assigns
pry/txt/xa1..xa9, then rewrite the header comments to reflect the correct
mapping of group numbers to palettes and the true tone numbers/direction used
for pry and txt (and the xa1–xa9 ordering) so the documentation mirrors the
code.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 3f90e32c-db58-4246-a40f-a204601450e4
📒 Files selected for processing (3)
Configs/.local/lib/hyde/wallbash-matugen.shConfigs/.local/lib/hyde/wallpaper/cache.shScripts/pkg_extra.lst
28e3739 to
039cbff
Compare
|
Closes #1701 |
|
wow!!! 🤯 You beat me to it! So just to be sure if I understand this. As wallbash uses magick to cache .dcol files. We are also implementing the same logic but using matugen right? I did not check the script's full logic but can we coexist both? maybe we can Output a In our theming script we can just source it and whatever color exist wins or if backend was set try to use it. And I said I planned 2 approaches. 1st is this PR's implementation. Second is having a matugen template. This one's kinda complex because we need to resolve what template to use and explicitly switching them means we won't have a wallbash fallback, if matugen doesn't have the template. And more of this soon let's polish this matugen caching for now. |
The Wiki submodule points to a repo that no longer exists and .gitmodules was already removed. Clean up the dangling gitlink.
|
Thanks! Yes, you've got it exactly right. Current implementation: Your
Then the theming script ( # Pseudocode for color.set.sh sourcing logic:
if [[ "$DCOL_BACKEND" == "matugen" ]] && [[ -f "$mcol_file" ]]; then
source "$mcol_file"
elif [[ -f "$dcol_file" ]]; then
source "$dcol_file"
fiThis way:
I'll update the PR to implement the Re: approach #2 (matugen templates) — agreed, let's nail the caching layer first. The template approach would be a separate feature on top of this foundation. |
Instead of replacing .dcol with matugen output, generate both: - hash.dcol = imagemagick dominant colors (always generated) - hash.mcol = matugen material colors (generated if matugen installed) color.set.sh sources the appropriate file based on DCOL_BACKEND: - unset/imagemagick: sources .dcol (default, no behavior change) - matugen: sources .mcol if available, falls back to .dcol This allows instant backend switching without cache regeneration.
|
opencode just auto answered you ahahhaha didnt notice was running still |
|
Updated! The implementation now uses the How it works now:
Benefits:
Files changed:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@Configs/.local/lib/hyde/color.set.sh`:
- Around line 164-166: The current cache-generation branch only checks for
dcol_file and will skip regeneration when an older .dcol exists even if
DCOL_BACKEND=matugen and the .mcol cache is missing; update the condition around
the call to "$scrDir/wallpaper/cache.sh" (the block using dcol_file,
wallbash_image and scrDir/wallpaper/cache.sh) so it also triggers when
DCOL_BACKEND equals "matugen" and the mcol_file is absent (i.e., regenerate if [
! -f "$dcol_file" ] || { [ "$DCOL_BACKEND" = "matugen" ] && [ ! -f "$mcol_file"
]; } ), and apply the same change to the similar block at 171-175.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: da69f846-691b-40e9-8a18-44925700f4d1
📒 Files selected for processing (3)
Configs/.local/lib/hyde/color.set.shConfigs/.local/lib/hyde/wallbash-matugen.shConfigs/.local/lib/hyde/wallpaper/cache.sh
🚧 Files skipped from review as they are similar to previous changes (2)
- Configs/.local/lib/hyde/wallpaper/cache.sh
- Configs/.local/lib/hyde/wallbash-matugen.sh
|
Now I think it is done, any other comment on this? |
|
Ohhhh I scanned through the code but isn't it better to use full python for the wallbash equivalent? This way it is easier to debug. Any reason for the design? matugen.py is fine for this IMO. |
|
The only reason was to mirror wallbash.sh |
|
Added a command for hyde-shell dcol.backend --get # prints current backend
hyde-shell dcol.backend --set matugen # switches to matugen
hyde-shell dcol.backend --set imagemagick # switches back
hyde-shell dcol.backend --select # rofi picker |
|
Let's call it |
|
Done |
This comment was marked as outdated.
This comment was marked as outdated.
|
This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days. |
Summary
Adds optional matugen (Material You color generation) support as an alternative color extraction backend for wallbash/dcol. This addresses the long-standing issue where some users' systems fail to extract colors via imagemagick.
Closes #1701
What this does
wallbash-matugen.sh— Drop-in alternative towallbash.shthat generates an identical 89-line.dcolfile using matugen's tonal palettes instead of imagemagick's k-means clustering.wallpaper/cache.sh— Addedfn_generate_dcol()dispatcher function that routes dcol generation to the appropriate backend based on user configuration.pkg_extra.lst— Addedmatugen-binas an optional (commented) package.Configuration
Users can set
DCOL_BACKENDin their Hyde config:imagemagickmatugenautoHow the mapping works
Matugen generates Material You tonal palettes (6 palettes × 18 tones). These are mapped to dcol's 4-group structure:
neutralprimarysecondarytertiaryEach group maps 9 tones to
xa1–xa9(dark→bright in dark mode, reversed in light mode).Why matugen?
DCOL_BACKEND, behavior is 100% unchanged.Testing
Dependencies
matugen-bin(AUR) — only required if user opts into matugen backendpython3— already a HyDE dependency (used for JSON parsing in wallbash-matugen.sh)Summary by CodeRabbit