Early matugen implementation
This commit is contained in:
parent
44656911cb
commit
2bdff80599
9 changed files with 162 additions and 120 deletions
28
Assets/Matugen/matugen.toml
Normal file
28
Assets/Matugen/matugen.toml
Normal file
|
|
@ -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"
|
||||||
26
Assets/Matugen/templates/noctalia.json
Normal file
26
Assets/Matugen/templates/noctalia.json
Normal file
|
|
@ -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}}"
|
||||||
|
}
|
||||||
|
|
@ -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 }}"
|
|
||||||
}
|
|
||||||
|
|
@ -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' }
|
|
||||||
62
Bin/matugen-theme.sh
Executable file
62
Bin/matugen-theme.sh
Executable file
|
|
@ -0,0 +1,62 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# matugen-theme.sh - Generate theme colors from wallpaper using matugen
|
||||||
|
# Usage: ./matugen-theme.sh <wallpaper_path>
|
||||||
|
|
||||||
|
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 <wallpaper_path>"
|
||||||
|
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"
|
||||||
|
|
@ -95,7 +95,7 @@ ColumnLayout {
|
||||||
// Use Wallpaper Theme
|
// Use Wallpaper Theme
|
||||||
NToggle {
|
NToggle {
|
||||||
label: "Use Wallpaper Theme"
|
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
|
value: Settings.data.wallpaper.generateTheme
|
||||||
onToggled: function (newValue) {
|
onToggled: function (newValue) {
|
||||||
Settings.data.wallpaper.generateTheme = newValue
|
Settings.data.wallpaper.generateTheme = newValue
|
||||||
|
|
|
||||||
|
|
@ -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`)
|
- `xdg-desktop-portal-gnome` or any other xdg-desktop-portal (for `gpu-screen-recorder`)
|
||||||
- `material-symbols-git` so the icons properly show up
|
- `material-symbols-git` so the icons properly show up
|
||||||
- `swww` to add fancy wallpaper animations (optional)
|
- `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
|
## zigstat and zigbrightness
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,41 +9,41 @@ Singleton {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
// Backgrounds
|
// Backgrounds
|
||||||
property color backgroundPrimary: useWallust ? wallustTheme.backgroundPrimary : defaultTheme.backgroundPrimary
|
property color backgroundPrimary: useMatugen ? matugenTheme.backgroundPrimary : defaultTheme.backgroundPrimary
|
||||||
property color backgroundSecondary: useWallust ? wallustTheme.backgroundSecondary : defaultTheme.backgroundSecondary
|
property color backgroundSecondary: useMatugen ? matugenTheme.backgroundSecondary : defaultTheme.backgroundSecondary
|
||||||
property color backgroundTertiary: useWallust ? wallustTheme.backgroundTertiary : defaultTheme.backgroundTertiary
|
property color backgroundTertiary: useMatugen ? matugenTheme.backgroundTertiary : defaultTheme.backgroundTertiary
|
||||||
|
|
||||||
// Surfaces & Elevation
|
// Surfaces & Elevation
|
||||||
property color surface: useWallust ? wallustTheme.surface : defaultTheme.surface
|
property color surface: useMatugen ? matugenTheme.surface : defaultTheme.surface
|
||||||
property color surfaceVariant: useWallust ? wallustTheme.surfaceVariant : defaultTheme.surfaceVariant
|
property color surfaceVariant: useMatugen ? matugenTheme.surfaceVariant : defaultTheme.surfaceVariant
|
||||||
|
|
||||||
// Text Colors
|
// Text Colors
|
||||||
property color textPrimary: useWallust ? wallustTheme.textPrimary : defaultTheme.textPrimary
|
property color textPrimary: useMatugen ? matugenTheme.textPrimary : defaultTheme.textPrimary
|
||||||
property color textSecondary: useWallust ? wallustTheme.textSecondary : defaultTheme.textSecondary
|
property color textSecondary: useMatugen ? matugenTheme.textSecondary : defaultTheme.textSecondary
|
||||||
property color textDisabled: useWallust ? wallustTheme.textDisabled : defaultTheme.textDisabled
|
property color textDisabled: useMatugen ? matugenTheme.textDisabled : defaultTheme.textDisabled
|
||||||
|
|
||||||
// Accent Colors
|
// Accent Colors
|
||||||
property color accentPrimary: useWallust ? wallustTheme.accentPrimary : defaultTheme.accentPrimary
|
property color accentPrimary: useMatugen ? matugenTheme.accentPrimary : defaultTheme.accentPrimary
|
||||||
property color accentSecondary: useWallust ? wallustTheme.accentSecondary : defaultTheme.accentSecondary
|
property color accentSecondary: useMatugen ? matugenTheme.accentSecondary : defaultTheme.accentSecondary
|
||||||
property color accentTertiary: useWallust ? wallustTheme.accentTertiary : defaultTheme.accentTertiary
|
property color accentTertiary: useMatugen ? matugenTheme.accentTertiary : defaultTheme.accentTertiary
|
||||||
|
|
||||||
// Error/Warning
|
// Error/Warning
|
||||||
property color error: useWallust ? wallustTheme.error : defaultTheme.error
|
property color error: useMatugen ? matugenTheme.error : defaultTheme.error
|
||||||
property color warning: useWallust ? wallustTheme.warning : defaultTheme.warning
|
property color warning: useMatugen ? matugenTheme.warning : defaultTheme.warning
|
||||||
|
|
||||||
// Hover
|
// Hover
|
||||||
property color hover: useWallust ? wallustTheme.hover : defaultTheme.hover
|
property color hover: useMatugen ? matugenTheme.hover : defaultTheme.hover
|
||||||
|
|
||||||
// Additional Theme Properties
|
// Additional Theme Properties
|
||||||
property color onAccent: useWallust ? wallustTheme.onAccent : defaultTheme.onAccent
|
property color onAccent: useMatugen ? matugenTheme.onAccent : defaultTheme.onAccent
|
||||||
property color outline: useWallust ? wallustTheme.outline : defaultTheme.outline
|
property color outline: useMatugen ? matugenTheme.outline : defaultTheme.outline
|
||||||
|
|
||||||
// Shadows & Overlays
|
// Shadows & Overlays
|
||||||
property color shadow: applyOpacity(useWallust ? wallustTheme.shadow : defaultTheme.shadow, "B3")
|
property color shadow: applyOpacity(useMatugen ? matugenTheme.shadow : defaultTheme.shadow, "B3")
|
||||||
property color overlay: applyOpacity(useWallust ? wallustTheme.overlay : defaultTheme.overlay, "66")
|
property color overlay: applyOpacity(useMatugen ? matugenTheme.overlay : defaultTheme.overlay, "66")
|
||||||
|
|
||||||
// Check if we should use Wallust theme
|
// Check if we should use Matugen theme
|
||||||
property bool useWallust: Settings.data.wallpaper.generateTheme && wallustFile.loaded
|
property bool useMatugen: Settings.data.wallpaper.generateTheme && matugenFile.loaded
|
||||||
|
|
||||||
function applyOpacity(color, opacity) {
|
function applyOpacity(color, opacity) {
|
||||||
// Convert color to string and apply opacity
|
// Convert color to string and apply opacity
|
||||||
|
|
@ -81,40 +81,40 @@ Singleton {
|
||||||
property color overlay: "#191724"
|
property color overlay: "#191724"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wallust theme colors (loaded from theme.json)
|
// Matugen theme colors (loaded from theme.json)
|
||||||
QtObject {
|
QtObject {
|
||||||
id: wallustTheme
|
id: matugenTheme
|
||||||
|
|
||||||
property color backgroundPrimary: wallustData.backgroundPrimary
|
property color backgroundPrimary: matugenData.backgroundPrimary
|
||||||
property color backgroundSecondary: wallustData.backgroundSecondary
|
property color backgroundSecondary: matugenData.backgroundSecondary
|
||||||
property color backgroundTertiary: wallustData.backgroundTertiary
|
property color backgroundTertiary: matugenData.backgroundTertiary
|
||||||
|
|
||||||
property color surface: wallustData.surface
|
property color surface: matugenData.surface
|
||||||
property color surfaceVariant: wallustData.surfaceVariant
|
property color surfaceVariant: matugenData.surfaceVariant
|
||||||
|
|
||||||
property color textPrimary: wallustData.textPrimary
|
property color textPrimary: matugenData.textPrimary
|
||||||
property color textSecondary: wallustData.textSecondary
|
property color textSecondary: matugenData.textSecondary
|
||||||
property color textDisabled: wallustData.textDisabled
|
property color textDisabled: matugenData.textDisabled
|
||||||
|
|
||||||
property color accentPrimary: wallustData.accentPrimary
|
property color accentPrimary: matugenData.accentPrimary
|
||||||
property color accentSecondary: wallustData.accentSecondary
|
property color accentSecondary: matugenData.accentSecondary
|
||||||
property color accentTertiary: wallustData.accentTertiary
|
property color accentTertiary: matugenData.accentTertiary
|
||||||
|
|
||||||
property color error: wallustData.error
|
property color error: matugenData.error
|
||||||
property color warning: wallustData.warning
|
property color warning: matugenData.warning
|
||||||
|
|
||||||
property color hover: wallustData.hover
|
property color hover: matugenData.hover
|
||||||
|
|
||||||
property color onAccent: wallustData.onAccent
|
property color onAccent: matugenData.onAccent
|
||||||
property color outline: wallustData.outline
|
property color outline: matugenData.outline
|
||||||
|
|
||||||
property color shadow: wallustData.shadow
|
property color shadow: matugenData.shadow
|
||||||
property color overlay: wallustData.overlay
|
property color overlay: matugenData.overlay
|
||||||
}
|
}
|
||||||
|
|
||||||
// FileView to load Wallust theme data from Theme.json
|
// FileView to load Matugen theme data from Theme.json
|
||||||
FileView {
|
FileView {
|
||||||
id: wallustFile
|
id: matugenFile
|
||||||
path: Settings.configDir + "theme.json"
|
path: Settings.configDir + "theme.json"
|
||||||
watchChanges: true
|
watchChanges: true
|
||||||
onFileChanged: reload()
|
onFileChanged: reload()
|
||||||
|
|
@ -126,7 +126,7 @@ Singleton {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
JsonAdapter {
|
JsonAdapter {
|
||||||
id: wallustData
|
id: matugenData
|
||||||
|
|
||||||
// Backgrounds
|
// Backgrounds
|
||||||
property string backgroundPrimary: "#191724"
|
property string backgroundPrimary: "#191724"
|
||||||
|
|
|
||||||
|
|
@ -155,12 +155,11 @@ Singleton {
|
||||||
|
|
||||||
Process {
|
Process {
|
||||||
id: generateThemeProcess
|
id: generateThemeProcess
|
||||||
command: ["wallust", "run", currentWallpaper, "-u", "-k", "-d", "Assets/Wallust"]
|
command: [Quickshell.shellDir + "/Bin/matugen-theme.sh", currentWallpaper]
|
||||||
workingDirectory: Quickshell.shellDir
|
workingDirectory: Quickshell.shellDir
|
||||||
running: false
|
running: false
|
||||||
stdout: StdioCollector {
|
stdout: StdioCollector {
|
||||||
onStreamFinished: {
|
onStreamFinished: {
|
||||||
|
|
||||||
// console.log(this.text)
|
// console.log(this.text)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue