From 2bdff80599e9f1eaa0bddc33c92e24be94e3f1fb Mon Sep 17 00:00:00 2001 From: Ly-sec Date: Thu, 14 Aug 2025 15:17:54 +0200 Subject: [PATCH] Early matugen implementation --- Assets/Matugen/matugen.toml | 28 +++++++++ Assets/Matugen/templates/noctalia.json | 26 ++++++++ Assets/Wallust/templates/noctalia.json | 26 -------- Assets/Wallust/wallust.toml | 47 -------------- Bin/matugen-theme.sh | 62 +++++++++++++++++++ Modules/Settings/Tabs/Wallpaper.qml | 2 +- README.md | 2 +- Services/Colors.qml | 86 +++++++++++++------------- Services/Wallpapers.qml | 3 +- 9 files changed, 162 insertions(+), 120 deletions(-) create mode 100644 Assets/Matugen/matugen.toml create mode 100644 Assets/Matugen/templates/noctalia.json delete mode 100644 Assets/Wallust/templates/noctalia.json delete mode 100644 Assets/Wallust/wallust.toml create mode 100755 Bin/matugen-theme.sh diff --git a/Assets/Matugen/matugen.toml b/Assets/Matugen/matugen.toml new file mode 100644 index 0000000..ad2bf57 --- /dev/null +++ b/Assets/Matugen/matugen.toml @@ -0,0 +1,28 @@ +# matugen configuration for Noctalia +# This file configures how matugen generates colors from wallpapers + +[config] +# Color scheme type for generation +scheme = "dark" + +# Color space for color extraction +color_space = "oklch" + +# Algorithm for color extraction +algorithm = "kmeans" + +# Number of colors to extract +color_count = 16 + +# Use source image colors +use_source_colors = true + +# Generate dark theme variant +generate_dark = true + +# Generate light theme variant +generate_light = false + +[templates.noctalia] +input_path = "templates/noctalia.json" +output_path = "~/.config/noctalia/theme.json" \ No newline at end of file diff --git a/Assets/Matugen/templates/noctalia.json b/Assets/Matugen/templates/noctalia.json new file mode 100644 index 0000000..35e857f --- /dev/null +++ b/Assets/Matugen/templates/noctalia.json @@ -0,0 +1,26 @@ +{ + "backgroundPrimary": "{{colors.surface_dim.default.hex}}", + "backgroundSecondary": "{{colors.surface.default.hex}}", + "backgroundTertiary": "{{colors.surface_bright.default.hex}}", + + "surface": "{{colors.surface.default.hex}}", + "surfaceVariant": "{{colors.surface_variant.default.hex}}", + + "textPrimary": "{{colors.on_surface.default.hex}}", + "textSecondary": "{{colors.on_surface_variant.default.hex}}", + "textDisabled": "{{colors.on_surface_variant.default.hex}}", + + "accentPrimary": "{{colors.primary.default.hex}}", + "accentSecondary": "{{colors.secondary.default.hex}}", + "accentTertiary": "{{colors.tertiary.default.hex}}", + + "error": "{{colors.error.default.hex}}", + "warning": "{{colors.error_container.default.hex}}", + + "hover": "{{colors.primary_container.default.hex}}", + "onAccent": "{{colors.on_primary.default.hex}}", + "outline": "{{colors.outline.default.hex}}", + + "shadow": "{{colors.shadow.default.hex}}", + "overlay": "{{colors.scrim.default.hex}}" +} \ No newline at end of file diff --git a/Assets/Wallust/templates/noctalia.json b/Assets/Wallust/templates/noctalia.json deleted file mode 100644 index ee4ba3b..0000000 --- a/Assets/Wallust/templates/noctalia.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "backgroundPrimary": "{{ background }}", - "backgroundSecondary": "{{ background | lighten(0.03) }}", - "backgroundTertiary": "{{ background | lighten(0.06) }}", - - "surface": "{{ background | lighten(0.01) }}", - "surfaceVariant": "{{ background | lighten(0.07) }}", - - "textPrimary": "{{ foreground }}", - "textSecondary": "{{ foreground | darken(0.25) }}", - "textDisabled": "{{ foreground | darken(0.5) }}", - - "accentPrimary": "{{ color1 }}", - "accentSecondary": "{{ color6 }}", - "accentTertiary": "{{ color4 }}", - - "error": "{{ color5 | saturate(0.5) }}", - "warning": "{{ color6 | saturate(0.4) }}", - - "hover": "{{ color14 }}", - "onAccent": "{{ background }}", - "outline": "{{ background | lighten(0.15) }}", - - "shadow": "{{ background }}", - "overlay": "{{ background }}" -} \ No newline at end of file diff --git a/Assets/Wallust/wallust.toml b/Assets/Wallust/wallust.toml deleted file mode 100644 index a27a0b3..0000000 --- a/Assets/Wallust/wallust.toml +++ /dev/null @@ -1,47 +0,0 @@ -# wallust v3.3 -# -# You can copy this file to ~/.config/wallust/wallust.toml (keep in mind is a sample config) - -# SIMPLE TUTORIAL, or `man wallust.5`: -# https://explosion-mental.codeberg.page/wallust/ -# -# If comming from v2: https://explosion-mental.codeberg.page/wallust/v3.html#wallusttoml - -# Global section - values below can be overwritten by command line flags - -# How the image is parse, in order to get the colors: -# full - resized - wal - thumb - fastresize - kmeans -backend = "resized" - -# What color space to use to produce and select the most prominent colors: -# lab - labmixed - lch - lchmixed -color_space = "labmixed" - -# Use the most prominent colors in a way that makes sense, a scheme color palette: -# dark - dark16 - darkcomp - darkcomp16 -# light - light16 - lightcomp - lightcomp16 -# harddark - harddark16 - harddarkcomp - harddarkcomp16 -# softdark - softdark16 - softdarkcomp - softdarkcomp16 -# softlight - softlight16 - softlightcomp - softlightcomp16 -palette = "dark" - -# Ensures a "readable contrast" (OPTIONAL, disabled by default) -# Should only be enabled when you notice an unreadable contrast frequently happening -# with your images. The reference color for the contrast is the background color. -check_contrast = true - -# Color saturation, between [1% and 100%] (OPTIONAL, disabled by default) -# usually something higher than 50 increases the saturation and below -# decreases it (on a scheme with strong and vivid colors) -#saturation = 50 - -# Alpha value for templating, by default 100 (no other use whatsoever) -#alpha = 100 - -[templates] -# NOTE: prefer '' over "" for paths, avoids escaping. -# template: A RELATIVE path that points to `~/.config/wallust/template` (depends on platform) -# target: ABSOLUTE path in which to place a file with generated templated values. -# ยก If either one is a directory, then both SHOULD be one. ! -# zathura = { template = 'zathura', target = '~/.config/zathura/zathurarc' } -Noctalia = { template = 'noctalia.json', target = '~/.config/noctalia/theme.json' } \ No newline at end of file diff --git a/Bin/matugen-theme.sh b/Bin/matugen-theme.sh new file mode 100755 index 0000000..73c18ca --- /dev/null +++ b/Bin/matugen-theme.sh @@ -0,0 +1,62 @@ +#!/bin/bash + +# matugen-theme.sh - Generate theme colors from wallpaper using matugen +# Usage: ./matugen-theme.sh + +set -e + +# Configuration +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +PROJECT_DIR="$(dirname "$SCRIPT_DIR")" +CONFIG_FILE="$PROJECT_DIR/Assets/Matugen/matugen.toml" +TEMPLATE_FILE="$PROJECT_DIR/Assets/Matugen/templates/noctalia.json" +OUTPUT_DIR="$HOME/.config/noctalia" +OUTPUT_FILE="$OUTPUT_DIR/theme.json" + +# Check if wallpaper path is provided +if [ $# -eq 0 ]; then + echo "Error: No wallpaper path provided" + echo "Usage: $0 " + exit 1 +fi + +WALLPAPER_PATH="$1" + +# Check if wallpaper exists +if [ ! -f "$WALLPAPER_PATH" ]; then + echo "Error: Wallpaper file not found: $WALLPAPER_PATH" + exit 1 +fi + +# Create output directory if it doesn't exist +mkdir -p "$OUTPUT_DIR" + +# Generate theme using matugen +echo "Generating theme from wallpaper: $WALLPAPER_PATH" + +# Use matugen to generate colors and transform to our format +matugen image "$WALLPAPER_PATH" \ + --config "$CONFIG_FILE" \ + --json hex | jq -c ' +{ + "backgroundPrimary": .colors.dark.surface_dim, + "backgroundSecondary": .colors.dark.surface, + "backgroundTertiary": .colors.dark.surface_bright, + "surface": .colors.dark.surface, + "surfaceVariant": .colors.dark.surface_variant, + "textPrimary": .colors.dark.on_surface, + "textSecondary": .colors.dark.on_surface_variant, + "textDisabled": .colors.dark.on_surface_variant, + "accentPrimary": .colors.dark.primary, + "accentSecondary": .colors.dark.secondary, + "accentTertiary": .colors.dark.tertiary, + "error": .colors.dark.error, + "warning": .colors.dark.error_container, + "hover": .colors.dark.primary_container, + "onAccent": .colors.dark.on_primary, + "outline": .colors.dark.outline, + "shadow": .colors.dark.shadow, + "overlay": .colors.dark.scrim +}' > "$OUTPUT_FILE.tmp" && mv "$OUTPUT_FILE.tmp" "$OUTPUT_FILE" + +echo "Theme generated successfully: $OUTPUT_FILE" \ No newline at end of file diff --git a/Modules/Settings/Tabs/Wallpaper.qml b/Modules/Settings/Tabs/Wallpaper.qml index f5f92d2..4520be1 100644 --- a/Modules/Settings/Tabs/Wallpaper.qml +++ b/Modules/Settings/Tabs/Wallpaper.qml @@ -95,7 +95,7 @@ ColumnLayout { // Use Wallpaper Theme NToggle { label: "Use Wallpaper Theme" - description: "Automatically adjust theme colors based on wallpaper" + description: "Automatically adjust theme colors based on wallpaper using Matugen" value: Settings.data.wallpaper.generateTheme onToggled: function (newValue) { Settings.data.wallpaper.generateTheme = newValue diff --git a/README.md b/README.md index c45dd33..be2389b 100644 --- a/README.md +++ b/README.md @@ -196,7 +196,7 @@ You will need to install a few things to get everything working: - `xdg-desktop-portal-gnome` or any other xdg-desktop-portal (for `gpu-screen-recorder`) - `material-symbols-git` so the icons properly show up - `swww` to add fancy wallpaper animations (optional) -- `wallust` to theme the setup based on wallpaper (optional) +- `matugen` to theme the setup based on wallpaper (optional) ## zigstat and zigbrightness diff --git a/Services/Colors.qml b/Services/Colors.qml index c5dc26f..45afb9b 100644 --- a/Services/Colors.qml +++ b/Services/Colors.qml @@ -9,41 +9,41 @@ Singleton { id: root // Backgrounds - property color backgroundPrimary: useWallust ? wallustTheme.backgroundPrimary : defaultTheme.backgroundPrimary - property color backgroundSecondary: useWallust ? wallustTheme.backgroundSecondary : defaultTheme.backgroundSecondary - property color backgroundTertiary: useWallust ? wallustTheme.backgroundTertiary : defaultTheme.backgroundTertiary + property color backgroundPrimary: useMatugen ? matugenTheme.backgroundPrimary : defaultTheme.backgroundPrimary + property color backgroundSecondary: useMatugen ? matugenTheme.backgroundSecondary : defaultTheme.backgroundSecondary + property color backgroundTertiary: useMatugen ? matugenTheme.backgroundTertiary : defaultTheme.backgroundTertiary // Surfaces & Elevation - property color surface: useWallust ? wallustTheme.surface : defaultTheme.surface - property color surfaceVariant: useWallust ? wallustTheme.surfaceVariant : defaultTheme.surfaceVariant + property color surface: useMatugen ? matugenTheme.surface : defaultTheme.surface + property color surfaceVariant: useMatugen ? matugenTheme.surfaceVariant : defaultTheme.surfaceVariant // Text Colors - property color textPrimary: useWallust ? wallustTheme.textPrimary : defaultTheme.textPrimary - property color textSecondary: useWallust ? wallustTheme.textSecondary : defaultTheme.textSecondary - property color textDisabled: useWallust ? wallustTheme.textDisabled : defaultTheme.textDisabled + property color textPrimary: useMatugen ? matugenTheme.textPrimary : defaultTheme.textPrimary + property color textSecondary: useMatugen ? matugenTheme.textSecondary : defaultTheme.textSecondary + property color textDisabled: useMatugen ? matugenTheme.textDisabled : defaultTheme.textDisabled // Accent Colors - property color accentPrimary: useWallust ? wallustTheme.accentPrimary : defaultTheme.accentPrimary - property color accentSecondary: useWallust ? wallustTheme.accentSecondary : defaultTheme.accentSecondary - property color accentTertiary: useWallust ? wallustTheme.accentTertiary : defaultTheme.accentTertiary + property color accentPrimary: useMatugen ? matugenTheme.accentPrimary : defaultTheme.accentPrimary + property color accentSecondary: useMatugen ? matugenTheme.accentSecondary : defaultTheme.accentSecondary + property color accentTertiary: useMatugen ? matugenTheme.accentTertiary : defaultTheme.accentTertiary // Error/Warning - property color error: useWallust ? wallustTheme.error : defaultTheme.error - property color warning: useWallust ? wallustTheme.warning : defaultTheme.warning + property color error: useMatugen ? matugenTheme.error : defaultTheme.error + property color warning: useMatugen ? matugenTheme.warning : defaultTheme.warning // Hover - property color hover: useWallust ? wallustTheme.hover : defaultTheme.hover + property color hover: useMatugen ? matugenTheme.hover : defaultTheme.hover // Additional Theme Properties - property color onAccent: useWallust ? wallustTheme.onAccent : defaultTheme.onAccent - property color outline: useWallust ? wallustTheme.outline : defaultTheme.outline + property color onAccent: useMatugen ? matugenTheme.onAccent : defaultTheme.onAccent + property color outline: useMatugen ? matugenTheme.outline : defaultTheme.outline // Shadows & Overlays - property color shadow: applyOpacity(useWallust ? wallustTheme.shadow : defaultTheme.shadow, "B3") - property color overlay: applyOpacity(useWallust ? wallustTheme.overlay : defaultTheme.overlay, "66") + property color shadow: applyOpacity(useMatugen ? matugenTheme.shadow : defaultTheme.shadow, "B3") + property color overlay: applyOpacity(useMatugen ? matugenTheme.overlay : defaultTheme.overlay, "66") - // Check if we should use Wallust theme - property bool useWallust: Settings.data.wallpaper.generateTheme && wallustFile.loaded + // Check if we should use Matugen theme + property bool useMatugen: Settings.data.wallpaper.generateTheme && matugenFile.loaded function applyOpacity(color, opacity) { // Convert color to string and apply opacity @@ -81,40 +81,40 @@ Singleton { property color overlay: "#191724" } - // Wallust theme colors (loaded from theme.json) + // Matugen theme colors (loaded from theme.json) QtObject { - id: wallustTheme + id: matugenTheme - property color backgroundPrimary: wallustData.backgroundPrimary - property color backgroundSecondary: wallustData.backgroundSecondary - property color backgroundTertiary: wallustData.backgroundTertiary + property color backgroundPrimary: matugenData.backgroundPrimary + property color backgroundSecondary: matugenData.backgroundSecondary + property color backgroundTertiary: matugenData.backgroundTertiary - property color surface: wallustData.surface - property color surfaceVariant: wallustData.surfaceVariant + property color surface: matugenData.surface + property color surfaceVariant: matugenData.surfaceVariant - property color textPrimary: wallustData.textPrimary - property color textSecondary: wallustData.textSecondary - property color textDisabled: wallustData.textDisabled + property color textPrimary: matugenData.textPrimary + property color textSecondary: matugenData.textSecondary + property color textDisabled: matugenData.textDisabled - property color accentPrimary: wallustData.accentPrimary - property color accentSecondary: wallustData.accentSecondary - property color accentTertiary: wallustData.accentTertiary + property color accentPrimary: matugenData.accentPrimary + property color accentSecondary: matugenData.accentSecondary + property color accentTertiary: matugenData.accentTertiary - property color error: wallustData.error - property color warning: wallustData.warning + property color error: matugenData.error + property color warning: matugenData.warning - property color hover: wallustData.hover + property color hover: matugenData.hover - property color onAccent: wallustData.onAccent - property color outline: wallustData.outline + property color onAccent: matugenData.onAccent + property color outline: matugenData.outline - property color shadow: wallustData.shadow - property color overlay: wallustData.overlay + property color shadow: matugenData.shadow + property color overlay: matugenData.overlay } - // FileView to load Wallust theme data from Theme.json + // FileView to load Matugen theme data from Theme.json FileView { - id: wallustFile + id: matugenFile path: Settings.configDir + "theme.json" watchChanges: true onFileChanged: reload() @@ -126,7 +126,7 @@ Singleton { } } JsonAdapter { - id: wallustData + id: matugenData // Backgrounds property string backgroundPrimary: "#191724" diff --git a/Services/Wallpapers.qml b/Services/Wallpapers.qml index 6a0c183..300db58 100644 --- a/Services/Wallpapers.qml +++ b/Services/Wallpapers.qml @@ -155,12 +155,11 @@ Singleton { Process { id: generateThemeProcess - command: ["wallust", "run", currentWallpaper, "-u", "-k", "-d", "Assets/Wallust"] + command: [Quickshell.shellDir + "/Bin/matugen-theme.sh", currentWallpaper] workingDirectory: Quickshell.shellDir running: false stdout: StdioCollector { onStreamFinished: { - // console.log(this.text) } }