Skip to content

Conversation

@ZODIAC3K
Copy link

@ZODIAC3K ZODIAC3K commented Nov 10, 2025

Issue: #1128

Matugen was returning color objects with mode-based properties ({dark, default, light}) instead of hex strings when using --json hex flag. The getMatugenHex() function expected hex strings but received objects, causing errors like:

[Matugen] Invalid color properties (not hex colors): background (value: [object Object]), ...

The function getMatugenVariations() tried to access properties like matugenColors.primary expecting a hex string, but got an object instead.

Solution

Added destructuring logic in generateMatugenColors() to extract hex values from mode-based color objects:

  • Extracts the correct color based on the selected mode (dark or light)
  • Falls back to default if mode-specific color is not available
  • Handles edge cases (direct hex property, RGB values)
  • Added comprehensive comments documenting the structure transformation

Changes

src/services/matugen/index.ts

  • Added color object destructuring logic to extract hex values based on mode
  • Added detailed comments documenting the structure before/after destructuring
  • Removed excessive validation code
  • Added comment in getMatugenHex() clarifying it expects destructured hex strings

env.d.ts

  • Added TypeScript declaration for GIF file imports (*.gif)

src/style/optionsTrackers.ts

  • Fixed TypeScript error for connect() method on WallpaperService by adding type assertion to GObject.Object

.gitignore

  • Added pnpm-lock.yaml to ignore list

Testing

  • ✅ Matugen colors are correctly extracted from mode-based objects
  • ✅ Bar colors update correctly when wallpaper changes
  • ✅ Matugen works for both dark and light modes

Example

Before (what matugen returns):

{
    "colors": {
        "primary": { "dark": "#4dd0a6", "default": "#4dd0a6", "light": "#006c4c" },
        "background": { "dark": "#0f1512", "default": "#0f1512", "light": "#f5fbf6" }
    }
}

After (what we pass to getMatugenHex):

{
    "primary": "#4dd0a6", // extracted from obj[mode] or obj.default
    "background": "#0f1512"
}

…nd path normalization

- Added normalization of wallpaper paths to ensure valid image files are processed.
- Improved error messages and notifications for better user feedback when Matugen is disabled or when errors occur during color generation.
- Updated the color mapping logic to handle different color formats and ensure only hex strings are returned.
- Updated the connection method for wallpaperService to ensure it is treated as a GObject.Object, enhancing type safety and preventing potential runtime errors.
- Streamlined the process of extracting hex values from mode-based color objects by removing redundant checks and directly using the mode or default values.
- Improved code readability and maintainability while ensuring consistent handling of color formats.
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