From ace2860e7a81dfcdfd0cd4a3813a9c57ac524a42 Mon Sep 17 00:00:00 2001 From: Johannes Kresner Date: Sat, 29 Aug 2026 14:53:04 +0200 Subject: [PATCH] feat: wallpaper-driven theming + native wallpaper picker Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_013ZYoSQwwYWhJHLX6VBCGnF --- config/nushell/scripts/theme-switch.nu | 122 ----------- config/nushell/scripts/wallpaper-switch.nu | 73 +++++-- config/nushell/scripts/wallpaper-theme.nu | 186 ++++++++++++++++ .../catppuccin/latte/quickshell/Theme.qml | 36 ---- .../catppuccin/mocha/quickshell/Theme.qml | 36 ---- config/themes/catppuccin/palette.json | 58 +++++ home.nix | 1 + local_bin/random_wallpaper | 2 +- mutable_config/hypr/hyprland.lua | 3 +- .../quickshell/components/Bar/Bar.qml | 8 +- .../quickshell/components/Bar/TrayTooltip.qml | 2 +- .../ClipboardManager/ClipboardManager.qml | 19 +- .../CommandPalette/CommandPalette.qml | 19 +- .../components/LogoutMenu/LogoutMenu.qml | 2 +- .../Notifications/Notifications.qml | 2 +- .../quickshell/components/Shared/Button.qml | 14 +- .../components/Shared/ContextMenu.qml | 4 +- .../quickshell/components/Shared/Theme.qml | 28 ++- .../WallpaperPicker/WallpaperPicker.qml | 198 ++++++++++++++++++ mutable_config/quickshell/core/Theme.qml | 36 ---- mutable_config/quickshell/core/qmldir | 1 - mutable_config/quickshell/shell.qml | 29 +++ 22 files changed, 594 insertions(+), 285 deletions(-) delete mode 100755 config/nushell/scripts/theme-switch.nu create mode 100644 config/nushell/scripts/wallpaper-theme.nu delete mode 100644 config/themes/catppuccin/latte/quickshell/Theme.qml delete mode 100644 config/themes/catppuccin/mocha/quickshell/Theme.qml create mode 100644 config/themes/catppuccin/palette.json create mode 100644 mutable_config/quickshell/components/WallpaperPicker/WallpaperPicker.qml delete mode 100644 mutable_config/quickshell/core/Theme.qml delete mode 100644 mutable_config/quickshell/core/qmldir diff --git a/config/nushell/scripts/theme-switch.nu b/config/nushell/scripts/theme-switch.nu deleted file mode 100755 index 09d7ff5..0000000 --- a/config/nushell/scripts/theme-switch.nu +++ /dev/null @@ -1,122 +0,0 @@ -#!/usr/bin/env nu - -def apply-theme [selected: string] { - let choice = if $selected == "auto" { - let mode = (try { darkman get | str trim } catch { "" }) - if $mode == "dark" { - "mocha" - } else if $mode == "light" { - "latte" - } else { - let color_scheme = (bash -lc "gsettings get org.gnome.desktop.interface color-scheme 2>/dev/null || true" | str trim) - - if ($color_scheme | str contains "prefer-dark") { - "mocha" - } else if ($color_scheme | str contains "prefer-light") { - "latte" - } else { - let hour = (date now | format date "%H" | into int) - if ($hour >= 19 or $hour < 7) { "mocha" } else { "latte" } - } - } - } else { - $selected - } - - let wanted_darkman = if $choice == "mocha" { "dark" } else { "light" } - let current_darkman = (try { darkman get | str trim } catch { "" }) - if $current_darkman != "" and $current_darkman != $wanted_darkman { - try { - bash -c $"darkman set ($wanted_darkman) &" - } catch {} - } - - let home = $env.HOME - let base = $"($home)/.config/themes/catppuccin/($choice)" - - if not ($base | path exists) { - exit 1 - } - - let gtk_theme = (open $"($base)/gtk-theme-name" | str trim) - - $choice | save -f $"($home)/.config/current-theme" - - # Hypr palette. Configs must source ~/.config/hypr/theme.conf to use this. - ln -sfn $"($base)/hypr.conf" $"($home)/.config/hypr/theme.conf" - - # Quickshell singleton theme. - cp -f $"($base)/quickshell/Theme.qml" $"($home)/.config/quickshell/Theme/Theme.qml" - - # Wofi colors. - if ($"($home)/.config/wofi" | path exists) { - ln -sfn $"($base)/wofi.css" $"($home)/.config/wofi/style.css" - } - - # Mako colors, only if mako config dir exists. - if ($"($home)/.config/mako" | path exists) { - ln -sfn $"($base)/mako.conf" $"($home)/.config/mako/config" - if (which makoctl | is-not-empty) { makoctl reload } - } - - # Btop theme - if ($"($home)/.config/btop/btop.conf" | path exists) { - bash -lc $"sed -i 's|color_theme = \".*\"|color_theme = \"($home)/.config/btop/themes/catppuccin_($choice).theme\"|' \"($home)/.config/btop/btop.conf\"" - if ($"($home)/.local/share/chezmoi/dot_config/btop/btop.conf" | path exists) { - bash -lc $"sed -i 's|color_theme = \".*\"|color_theme = \"($home)/.config/btop/themes/catppuccin_($choice).theme\"|' \"($home)/.local/share/chezmoi/dot_config/btop/btop.conf\"" - } - } - - # Helix theme - if ($"($home)/.config/helix/config.toml" | path exists) { - bash -lc $"sed -i 's/theme = \"catppuccin_.*_transparent\"/theme = \"catppuccin_($choice)_transparent\"/' \"($home)/.config/helix/config.toml\"" - if ($"($home)/.local/share/chezmoi/dot_config/helix/config.toml" | path exists) { - bash -lc $"sed -i 's/theme = \"catppuccin_.*_transparent\"/theme = \"catppuccin_($choice)_transparent\"/' \"($home)/.local/share/chezmoi/dot_config/helix/config.toml\"" - } - } - - # Yazi theme - if ($"($home)/.config/yazi" | path exists) { - $"[flavor]\nuse = \"catppuccin-($choice)\"\n" | save -f $"($home)/.config/yazi/theme.toml" - } - - # GTK theme, only if installed. - try { - bash -lc $"gsettings set org.gnome.desktop.interface gtk-theme ($gtk_theme)" - let color_scheme = if $choice == "mocha" { "prefer-dark" } else { "prefer-light" } - bash -lc $"gsettings set org.gnome.desktop.interface color-scheme ($color_scheme)" - - try { - mkdir $"($home)/.config/gtk-3.0" - } catch {} - let prefer_dark = if $choice == "mocha" { "1" } else { "0" } - $"[Settings]\ngtk-theme-name=($gtk_theme)\ngtk-application-prefer-dark-theme=($prefer_dark)\n" | save -f $"($home)/.config/gtk-3.0/settings.ini" - } catch { - } - - hyprctl reload - bash -lc "pkill quickshell 2>/dev/null; setsid quickshell >/tmp/quickshell-theme-switch.log 2>&1 < /dev/null &" -} - -def main [ - mode?: string - --auto - --mocha - --latte -] { - let valid = ["auto" "mocha" "latte"] - let selected = if $auto { - "auto" - } else if $mocha { - "mocha" - } else if $latte { - "latte" - } else if $mode == null { - ($valid | str join "\n" | wofi --dmenu --prompt "Theme") - } else { - $mode - } - - if ($selected not-in $valid) { exit } - apply-theme $selected -} diff --git a/config/nushell/scripts/wallpaper-switch.nu b/config/nushell/scripts/wallpaper-switch.nu index e843c99..c412d4d 100755 --- a/config/nushell/scripts/wallpaper-switch.nu +++ b/config/nushell/scripts/wallpaper-switch.nu @@ -4,8 +4,8 @@ const image_exts = ["jpg" "jpeg" "png" "webp"] def wallpaper-dirs [] { [ - ($"($env.HOME)/Nextcloud/Wallpaper") - ($"($env.HOME)/Nextcloud/Wallpaper_32x9") + ($"($env.HOME)/ownCloud/Personal/Wallpaper") + ($"($env.HOME)/ownCloud/Personal/Wallpaper_32x9") ] | where {|dir| $dir | path exists } } @@ -14,39 +14,63 @@ def list-wallpapers [] { | each {|dir| ls $dir } | flatten | where type == file - | where {|file| (($file.name | path parse | get extension | str downcase) in $image_exts) } + | where {|file| (($file.name | path parse | get extension | str lowercase) in $image_exts) } | sort-by name } +const thumb_size = "480x640" + +def thumbnail-dir [] { + let dir = $"($env.HOME)/.cache/quickshell-wallpaper-thumbs" + mkdir $dir + $dir +} + +def thumbnail-path [src: string] { + let hash = ($src | hash sha256 | str substring 0..24) + $"(thumbnail-dir)/($hash).jpg" +} + +# Pre-rendered small JPEG cached in ~/.cache, so the picker never has to +# decode a multi-megapixel wallpaper just to show a thumbnail. +def ensure-thumbnail [src: string] { + let thumb = (thumbnail-path $src) + if not ($thumb | path exists) { + try { + magick $src -auto-orient -thumbnail $"($thumb_size)^" -gravity center -extent $thumb_size -quality 85 $thumb + } catch {} + } + $thumb +} + +def list-wallpapers-with-thumbs [] { + list-wallpapers | get name | par-each {|f| { path: $f, thumb: (ensure-thumbnail $f) } } +} + def set-wallpaper [path: string] { if not ($path | path exists) { - notify-send "Wallpaper not found" $path + try { notify-send "Wallpaper not found" $path } exit 1 } - awww img $path --transition-type grow --transition-duration 1 + try { awww img $path --transition-type grow --transition-duration 1 } $path | save -f $"($env.HOME)/.config/current-wallpaper" - notify-send "Wallpaper applied" ($path | path basename) -} -def choose-wallpaper [] { - let files = (list-wallpapers) - if ($files | is-empty) { - notify-send "No wallpapers found" "~/Nextcloud/Wallpaper or ~/Nextcloud/Wallpaper_32x9" - exit 1 + # An unhandled external-command failure aborts the rest of a nu script, so + # this must not depend on awww/notify-send succeeding above. + try { + bash -lc $"nu ~/.dotfiles/config/nushell/scripts/wallpaper-theme.nu \"($path)\"" + } catch {|e| + try { notify-send "Theme update failed" $e.msg } } - let choice = ($files | get name | path basename | str join "\n" | wofi --dmenu --prompt "Wallpaper") - if ($choice == "") { exit } - - let selected = ($files | where {|file| ($file.name | path basename) == $choice } | get name | first) - set-wallpaper $selected + try { notify-send "Wallpaper applied" ($path | path basename) } } def random-wallpaper [] { let files = (list-wallpapers) if ($files | is-empty) { - notify-send "No wallpapers found" "~/Nextcloud/Wallpaper or ~/Nextcloud/Wallpaper_32x9" + notify-send "No wallpapers found" "~/ownCloud/Personal/Wallpaper or ~/ownCloud/Personal/Wallpaper_32x9" exit 1 } @@ -56,18 +80,23 @@ def random-wallpaper [] { def current-wallpaper [] { let file = $"($env.HOME)/.config/current-wallpaper" - if ($file | path exists) { open $file | str trim } + if ($file | path exists) { open $file | str trim } else { "" } } def main [ path?: string - --menu --random --set: string --current --list + --list-with-current ] { - if $list { + if $list_with_current { + { + wallpapers: (list-wallpapers-with-thumbs), + current: (current-wallpaper) + } | to json --raw + } else if $list { list-wallpapers | get name | to json --raw } else if $current { current-wallpaper @@ -78,6 +107,6 @@ def main [ } else if $path != null { set-wallpaper $path } else { - choose-wallpaper + notify-send "Wallpaper picker" "Use the mod+W wallpaper carousel instead" } } diff --git a/config/nushell/scripts/wallpaper-theme.nu b/config/nushell/scripts/wallpaper-theme.nu new file mode 100644 index 0000000..758a1e3 --- /dev/null +++ b/config/nushell/scripts/wallpaper-theme.nu @@ -0,0 +1,186 @@ +#!/usr/bin/env nu +# Derives a Catppuccin flavor + accent from a wallpaper's average color and +# applies it system-wide. No manual override - the wallpaper is the source of truth. + +def palette [] { + open ($"($env.HOME)/.dotfiles/config/themes/catppuccin/palette.json") +} + +def average-color [path: string] { + let out = (magick $path -resize 1x1 txt:- | lines | skip 1 | first) + let matches = ($out | parse --regex '\((?P\d+),(?P\d+),(?P\d+)\)') + if ($matches | is-empty) { + error make { msg: $"could not read average color from ($path)" } + } + let m = ($matches | first) + { r: ($m.r | into int), g: ($m.g | into int), b: ($m.b | into int) } +} + +def rgb-to-hsl [rgb: record] { + let r = $rgb.r / 255 + let g = $rgb.g / 255 + let b = $rgb.b / 255 + let max = ([$r $g $b] | math max) + let min = ([$r $g $b] | math min) + let l = ($max + $min) / 2 + let delta = $max - $min + + let s = if $delta == 0 { + 0 + } else { + $delta / (1 - (($l * 2 - 1) | math abs)) + } + + let h = if $delta == 0 { + 0 + } else if $max == $r { + (60 * ((($g - $b) / $delta) mod 6)) + } else if $max == $g { + (60 * ((($b - $r) / $delta) + 2)) + } else { + (60 * ((($r - $g) / $delta) + 4)) + } + let h = if $h < 0 { $h + 360 } else { $h } + + { h: $h, s: $s, l: $l } +} + +def hex-byte [] { + # "into int -r 16" misreads byte pairs like "0b" as a binary literal prefix. + $"0x($in)" | into int +} + +def hue-dist [a: float, b: float] { + let diff = (($a - $b) | math abs) + [$diff, 360 - $diff] | math min +} + +def pick-flavor [rgb: record] { + let luma = (0.299 * $rgb.r + 0.587 * $rgb.g + 0.114 * $rgb.b) / 255 + if $luma < 0.5 { "mocha" } else { "latte" } +} + +def pick-accent [flavor: string, rgb: record] { + let wallpaper_hsl = (rgb-to-hsl $rgb) + + # Near-gray wallpapers don't carry a meaningful hue - fall back to mauve. + if $wallpaper_hsl.s < 0.12 { + return "mauve" + } + + let accents = (palette | get $flavor | get accents) + $accents + | columns + | each {|name| + let hex = ($accents | get $name) + let r = ($hex | str substring 1..2 | hex-byte) + let g = ($hex | str substring 3..4 | hex-byte) + let b = ($hex | str substring 5..6 | hex-byte) + let accent_hsl = (rgb-to-hsl { r: $r, g: $g, b: $b }) + { name: $name, dist: (hue-dist $wallpaper_hsl.h $accent_hsl.h) } + } + | sort-by dist + | first + | get name +} + +def write-theme-colors [flavor: string, accent_name: string] { + let p = (palette | get $flavor) + let accent = ($p.accents | get $accent_name) + let border = $"#1a($accent | str substring 1..)" # accent-tinted, ~10% opacity + + let colors = [ + $" property color background: \"#e6($p.crust | str substring 1..)\"" + $" property color surface: \"#cc($p.mantle | str substring 1..)\"" + $" property color surfaceHover: \"#f2($p.surface0 | str substring 1..)\"" + $" property color overlay: \"#60($p.crust | str substring 1..)\"" + "" + $" property color primary: \"($accent)\"" + $" property color secondary: \"($p.accents.lavender)\"" + $" property color accent: \"($accent)\"" + $" property color alert: \"($p.red)\"" + $" property color success: \"($p.green)\"" + $" property color warning: \"($p.yellow)\"" + "" + $" property color text: \"($p.text)\"" + $" property color textMuted: \"($p.subtext0)\"" + "" + $" property color border: \"($border)\"" + ] + + let theme_path = $"($env.HOME)/.config/quickshell/components/Shared/Theme.qml" + let lines = (open --raw $theme_path | lines) + let begin = ($lines | enumerate | where item == " // GENERATED:COLORS:BEGIN" | get index.0) + let end = ($lines | enumerate | where item == " // GENERATED:COLORS:END" | get index.0) + + let new_lines = ( + ($lines | take ($begin + 1)) + ++ [" property QtObject colors: QtObject {"] + ++ $colors + ++ [" }"] + ++ ($lines | skip $end) + ) + + ($new_lines | str join "\n") + "\n" | save -f $theme_path +} + +def propagate [flavor: string] { + let home = $env.HOME + let base = $"($home)/.config/themes/catppuccin/($flavor)" + let gtk_theme = (open $"($base)/gtk-theme-name" | str trim) + + $flavor | save -f $"($home)/.config/current-theme" + + let wanted_darkman = if $flavor == "mocha" { "dark" } else { "light" } + let current_darkman = (try { darkman get | str trim } catch { "" }) + if $current_darkman != "" and $current_darkman != $wanted_darkman { + try { bash -c $"darkman set ($wanted_darkman) &" } catch {} + } + + # Hypr palette. Configs must source ~/.config/hypr/theme.conf to use this. + ln -sfn $"($base)/hypr.conf" $"($home)/.config/hypr/theme.conf" + + # Mako colors, only if mako config dir exists. + if ($"($home)/.config/mako" | path exists) { + ln -sfn $"($base)/mako.conf" $"($home)/.config/mako/config" + if (which makoctl | is-not-empty) { makoctl reload } + } + + # Btop theme + if ($"($home)/.config/btop/btop.conf" | path exists) { + bash -lc $"sed -i 's|color_theme = \".*\"|color_theme = \"($home)/.config/btop/themes/catppuccin_($flavor).theme\"|' \"($home)/.config/btop/btop.conf\"" + } + + # Helix theme + if ($"($home)/.config/helix/config.toml" | path exists) { + bash -lc $"sed -i 's/theme = \"catppuccin_.*_transparent\"/theme = \"catppuccin_($flavor)_transparent\"/' \"($home)/.config/helix/config.toml\"" + } + + # Yazi theme + if ($"($home)/.config/yazi" | path exists) { + $"[flavor]\nuse = \"catppuccin-($flavor)\"\n" | save -f $"($home)/.config/yazi/theme.toml" + } + + # GTK theme, only if installed. + try { + bash -lc $"gsettings set org.gnome.desktop.interface gtk-theme ($gtk_theme)" + let color_scheme = if $flavor == "mocha" { "prefer-dark" } else { "prefer-light" } + bash -lc $"gsettings set org.gnome.desktop.interface color-scheme ($color_scheme)" + + try { mkdir $"($home)/.config/gtk-3.0" } catch {} + let prefer_dark = if $flavor == "mocha" { "1" } else { "0" } + $"[Settings]\ngtk-theme-name=($gtk_theme)\ngtk-application-prefer-dark-theme=($prefer_dark)\n" | save -f $"($home)/.config/gtk-3.0/settings.ini" + } catch {} + + hyprctl reload + bash -lc "pkill quickshell 2>/dev/null; setsid quickshell >/tmp/quickshell-theme.log 2>&1 < /dev/null &" +} + +def main [wallpaper_path: string] { + let rgb = (average-color $wallpaper_path) + let flavor = (pick-flavor $rgb) + let accent = (pick-accent $flavor $rgb) + + write-theme-colors $flavor $accent + propagate $flavor +} diff --git a/config/themes/catppuccin/latte/quickshell/Theme.qml b/config/themes/catppuccin/latte/quickshell/Theme.qml deleted file mode 100644 index aca30e2..0000000 --- a/config/themes/catppuccin/latte/quickshell/Theme.qml +++ /dev/null @@ -1,36 +0,0 @@ -pragma Singleton -import QtQuick - -QtObject { - // Catppuccin Latte - property color base: "#eff1f5" - property color mantle: "#e6e9ef" - property color crust: "#dce0e8" - property color surface0: "#ccd0da" - property color surface1: "#bcc0cc" - property color surface2: "#acb0be" - property color overlay0: "#9ca0b0" - property color overlay1: "#8c8fa1" - property color overlay2: "#7c7f93" - property color text: "#4c4f69" - property color subtext0: "#6c6f85" - property color subtext1: "#5c5f77" - property color mauve: "#8839ef" - property color flamingo: "#dd7878" - property color peach: "#fe640b" - property color sky: "#04a5e5" - property color green: "#40a02b" - property color yellow: "#df8e1d" - property color red: "#d20f39" - property color rosewater: "#dc8a78" - - property real barHeight: 36 - property real padding: 10 - property real spacing: 10 - property real fontPixelSize: 14 - property string fontFamily: "Fira Code Nerd Font" - property real sectionRadius: 14 - property real sectionPadding: 12 - property real barMargin: 16 - property real widgetSpacing: 8 -} diff --git a/config/themes/catppuccin/mocha/quickshell/Theme.qml b/config/themes/catppuccin/mocha/quickshell/Theme.qml deleted file mode 100644 index 7d14a69..0000000 --- a/config/themes/catppuccin/mocha/quickshell/Theme.qml +++ /dev/null @@ -1,36 +0,0 @@ -pragma Singleton -import QtQuick - -QtObject { - // Catppuccin Mocha - property color base: "#1e1e2e" - property color mantle: "#181825" - property color crust: "#11111b" - property color surface0: "#313244" - property color surface1: "#45475a" - property color surface2: "#585b70" - property color overlay0: "#6c7086" - property color overlay1: "#7f849c" - property color overlay2: "#9399b2" - property color text: "#cdd6f4" - property color subtext0: "#a6adc8" - property color subtext1: "#bac2de" - property color mauve: "#cba6f7" - property color flamingo: "#f2cdcd" - property color peach: "#fab387" - property color sky: "#89dceb" - property color green: "#a6e3a1" - property color yellow: "#f9e2af" - property color red: "#f38ba8" - property color rosewater: "#f5e0dc" - - property real barHeight: 36 - property real padding: 10 - property real spacing: 10 - property real fontPixelSize: 14 - property string fontFamily: "Fira Code Nerd Font" - property real sectionRadius: 14 - property real sectionPadding: 12 - property real barMargin: 16 - property real widgetSpacing: 8 -} diff --git a/config/themes/catppuccin/palette.json b/config/themes/catppuccin/palette.json new file mode 100644 index 0000000..91a38ac --- /dev/null +++ b/config/themes/catppuccin/palette.json @@ -0,0 +1,58 @@ +{ + "mocha": { + "base": "#1e1e2e", + "mantle": "#181825", + "crust": "#11111b", + "surface0": "#313244", + "surface1": "#45475a", + "text": "#cdd6f4", + "subtext0": "#a6adc8", + "green": "#a6e3a1", + "yellow": "#f9e2af", + "red": "#f38ba8", + "accents": { + "rosewater": "#f5e0dc", + "flamingo": "#f2cdcd", + "pink": "#f5c2e7", + "mauve": "#cba6f7", + "red": "#f38ba8", + "maroon": "#eba0ac", + "peach": "#fab387", + "yellow": "#f9e2af", + "green": "#a6e3a1", + "teal": "#94e2d5", + "sky": "#89dceb", + "sapphire": "#74c7ec", + "blue": "#89b4fa", + "lavender": "#b4befe" + } + }, + "latte": { + "base": "#eff1f5", + "mantle": "#e6e9ef", + "crust": "#dce0e8", + "surface0": "#ccd0da", + "surface1": "#bcc0cc", + "text": "#4c4f69", + "subtext0": "#6c6f85", + "green": "#40a02b", + "yellow": "#df8e1d", + "red": "#d20f39", + "accents": { + "rosewater": "#dc8a78", + "flamingo": "#dd7878", + "pink": "#ea76cb", + "mauve": "#8839ef", + "red": "#d20f39", + "maroon": "#e64553", + "peach": "#fe640b", + "yellow": "#df8e1d", + "green": "#40a02b", + "teal": "#179299", + "sky": "#04a5e5", + "sapphire": "#209fb5", + "blue": "#1e66f5", + "lavender": "#7287fd" + } + } +} diff --git a/home.nix b/home.nix index f2547ae..935edb1 100644 --- a/home.nix +++ b/home.nix @@ -68,6 +68,7 @@ easyeffects lutris claude-code + imagemagick ]; home.file = { diff --git a/local_bin/random_wallpaper b/local_bin/random_wallpaper index 72dd52a..235d810 100755 --- a/local_bin/random_wallpaper +++ b/local_bin/random_wallpaper @@ -1,6 +1,6 @@ #!/usr/bin/env bash -DIR="$HOME/Nextcloud/Wallpaper" +DIR="$HOME/ownCloud/Personal/Wallpaper" INTERVAL=300 # seconds between changes awww init 2>/dev/null diff --git a/mutable_config/hypr/hyprland.lua b/mutable_config/hypr/hyprland.lua index b3da869..7acf894 100644 --- a/mutable_config/hypr/hyprland.lua +++ b/mutable_config/hypr/hyprland.lua @@ -192,8 +192,7 @@ hl.bind(mainMod .. " + comma", hl.dsp.layout("move -col")) hl.bind(mainMod .. " + SHIFT + period", hl.dsp.layout("swapcol r")) hl.bind(mainMod .. " + SHIFT + comma", hl.dsp.layout("swapcol l")) --- Theme / wallpaper switchers -hl.bind(mainMod .. " + T", hl.dsp.exec_cmd("qs ipc call themeSwitcher open")) +-- Wallpaper switcher (drives theme flavor + accent automatically) hl.bind(mainMod .. " + W", hl.dsp.exec_cmd("qs ipc call wallpaperSwitcher open")) hl.bind(mainMod .. " + SHIFT + W", hl.dsp.exec_cmd("qs ipc call wallpaperSwitcher random")) diff --git a/mutable_config/quickshell/components/Bar/Bar.qml b/mutable_config/quickshell/components/Bar/Bar.qml index 57be6a8..f263bd0 100644 --- a/mutable_config/quickshell/components/Bar/Bar.qml +++ b/mutable_config/quickshell/components/Bar/Bar.qml @@ -69,7 +69,7 @@ PanelWindow { delegate: Rectangle { width: 24 height: 24 - radius: 12 + radius: Theme.geometry.radiusTiny color: modelData.active ? Theme.colors.primary : Theme.colors.surfaceHover Text { @@ -112,7 +112,7 @@ PanelWindow { Text { id: clockText anchors.centerIn: parent - text: Qt.formatDateTime(clock.date, "hh:mm") + text: Qt.formatDateTime(clock.date, "dddd, MMMM d ยท hh:mm") color: Theme.colors.text font.family: Theme.font.family font.bold: true @@ -256,7 +256,7 @@ PanelWindow { Rectangle { anchors.fill: parent - radius: Theme.geometry.radius / 2 + radius: Theme.geometry.radiusTiny color: hoverArea.containsMouse ? Theme.colors.surfaceHover : (trayIcon.active ? Qt.alpha(Theme.colors.primary, 0.15) : "transparent") @@ -264,7 +264,7 @@ PanelWindow { Text { anchors.centerIn: parent text: trayIcon.glyph - font.family: "JetBrainsMono Nerd Font" + font.family: Theme.font.family font.pixelSize: 13 color: trayIcon.active ? Theme.colors.primary : Theme.colors.text } diff --git a/mutable_config/quickshell/components/Bar/TrayTooltip.qml b/mutable_config/quickshell/components/Bar/TrayTooltip.qml index bc16ecd..203f058 100644 --- a/mutable_config/quickshell/components/Bar/TrayTooltip.qml +++ b/mutable_config/quickshell/components/Bar/TrayTooltip.qml @@ -48,7 +48,7 @@ PanelWindow { Math.min(tooltipWindow.anchorX - width / 2, tooltipWindow.width - width - Theme.geometry.spacing) ) y: tooltipWindow.anchorY - radius: Theme.geometry.radius / 2 + radius: Theme.geometry.radiusMedium color: Theme.colors.background border.color: Theme.colors.border border.width: 1 diff --git a/mutable_config/quickshell/components/ClipboardManager/ClipboardManager.qml b/mutable_config/quickshell/components/ClipboardManager/ClipboardManager.qml index 8171568..5c1cb09 100644 --- a/mutable_config/quickshell/components/ClipboardManager/ClipboardManager.qml +++ b/mutable_config/quickshell/components/ClipboardManager/ClipboardManager.qml @@ -1,4 +1,5 @@ import QtQuick +import QtQuick.Effects import Quickshell import Quickshell.Wayland import Quickshell.Io @@ -35,7 +36,7 @@ PanelWindow { width: 800 height: Math.min(600, (clipList.count > 0 ? clipList.contentHeight : 0) + (searchInput.text.length > 0 ? 50 + Theme.geometry.spacing : 0) + Theme.geometry.padding * 2) anchors.centerIn: parent - radius: Theme.geometry.radius + radius: Theme.geometry.radiusMedium color: Theme.colors.background border.color: Theme.colors.border border.width: 1 @@ -61,7 +62,7 @@ PanelWindow { opacity: searchInput.text.length > 0 ? 1 : 0 clip: true color: Theme.colors.surface - radius: Theme.geometry.radius + radius: Theme.geometry.radiusSmall border.width: 1 border.color: searchInput.activeFocus ? Theme.colors.primary : Theme.colors.border @@ -69,6 +70,16 @@ PanelWindow { Behavior on opacity { NumberAnimation { duration: Theme.animation.durationFast } } Behavior on border.color { ColorAnimation { duration: Theme.animation.durationFast } } + layer.enabled: searchInput.activeFocus + layer.effect: MultiEffect { + shadowEnabled: true + shadowColor: Theme.colors.primary + shadowOpacity: 0.35 + shadowBlur: 0.4 + shadowHorizontalOffset: 0 + shadowVerticalOffset: 0 + } + TextInput { id: searchInput anchors.fill: parent @@ -150,8 +161,8 @@ PanelWindow { width: clipList.width height: 36 color: ListView.isCurrentItem ? Theme.colors.surfaceHover : "transparent" - radius: Theme.geometry.radius - + radius: Theme.geometry.radiusTiny + Item { anchors.fill: parent anchors.leftMargin: Theme.geometry.padding diff --git a/mutable_config/quickshell/components/CommandPalette/CommandPalette.qml b/mutable_config/quickshell/components/CommandPalette/CommandPalette.qml index ab74be8..0e16a33 100644 --- a/mutable_config/quickshell/components/CommandPalette/CommandPalette.qml +++ b/mutable_config/quickshell/components/CommandPalette/CommandPalette.qml @@ -1,4 +1,5 @@ import QtQuick +import QtQuick.Effects import Quickshell import Quickshell.Wayland import Quickshell.Services.Pipewire @@ -60,7 +61,7 @@ PanelWindow { width: 800 height: Math.min(600, (appList.count > 0 ? appList.contentHeight : 0) + (searchInput.text.length > 0 ? 50 + Theme.geometry.spacing : 0) + Theme.geometry.padding * 2) anchors.centerIn: parent - radius: Theme.geometry.radius + radius: Theme.geometry.radiusMedium color: Theme.colors.background border.color: Theme.colors.border border.width: 1 @@ -87,7 +88,7 @@ PanelWindow { opacity: searchInput.text.length > 0 ? 1 : 0 clip: true color: Theme.colors.surface - radius: Theme.geometry.radius + radius: Theme.geometry.radiusSmall border.width: 1 border.color: searchInput.activeFocus ? Theme.colors.primary : Theme.colors.border @@ -95,6 +96,16 @@ PanelWindow { Behavior on opacity { NumberAnimation { duration: Theme.animation.durationFast } } Behavior on border.color { ColorAnimation { duration: Theme.animation.durationFast } } + layer.enabled: searchInput.activeFocus + layer.effect: MultiEffect { + shadowEnabled: true + shadowColor: Theme.colors.primary + shadowOpacity: 0.35 + shadowBlur: 0.4 + shadowHorizontalOffset: 0 + shadowVerticalOffset: 0 + } + TextInput { id: searchInput anchors.fill: parent @@ -261,8 +272,8 @@ PanelWindow { width: appList.width height: 36 color: ListView.isCurrentItem ? Theme.colors.surfaceHover : "transparent" - radius: Theme.geometry.radius - + radius: Theme.geometry.radiusTiny + Item { anchors.fill: parent anchors.leftMargin: Theme.geometry.padding diff --git a/mutable_config/quickshell/components/LogoutMenu/LogoutMenu.qml b/mutable_config/quickshell/components/LogoutMenu/LogoutMenu.qml index b0adb1f..297e563 100644 --- a/mutable_config/quickshell/components/LogoutMenu/LogoutMenu.qml +++ b/mutable_config/quickshell/components/LogoutMenu/LogoutMenu.qml @@ -171,7 +171,7 @@ PanelWindow { width: 120 height: 120 - radius: Theme.geometry.radius + radius: Theme.geometry.radiusMedium color: Theme.colors.surface border.color: isSelected ? (isDestructive ? Theme.colors.alert : Theme.colors.primary) : Theme.colors.border border.width: isSelected ? 2 : 1 diff --git a/mutable_config/quickshell/components/Notifications/Notifications.qml b/mutable_config/quickshell/components/Notifications/Notifications.qml index c6485c1..0c4182a 100644 --- a/mutable_config/quickshell/components/Notifications/Notifications.qml +++ b/mutable_config/quickshell/components/Notifications/Notifications.qml @@ -105,7 +105,7 @@ PanelWindow { id: toast width: list.width height: content.implicitHeight + Theme.geometry.padding * 2 - radius: Theme.geometry.radius + radius: Theme.geometry.radiusMedium color: Qt.alpha(notifWindow.colorFor(model.urgency), 0.15) border.color: Qt.alpha(notifWindow.colorFor(model.urgency), 0.3) border.width: 1 diff --git a/mutable_config/quickshell/components/Shared/Button.qml b/mutable_config/quickshell/components/Shared/Button.qml index 81dd52b..67310aa 100644 --- a/mutable_config/quickshell/components/Shared/Button.qml +++ b/mutable_config/quickshell/components/Shared/Button.qml @@ -1,4 +1,5 @@ import QtQuick +import QtQuick.Effects import "." Rectangle { @@ -9,6 +10,8 @@ Rectangle { property string text: "" signal clicked() + // primary and accent are the same color (Theme.colors.primary === .accent); + // kept as separate variant names for call-site clarity. readonly property bool filled: variant === "primary" || variant === "accent" readonly property color tint: variant === "accent" ? Theme.colors.accent : variant === "destructive" ? Theme.colors.alert @@ -17,13 +20,22 @@ Rectangle { implicitWidth: label.implicitWidth + Theme.geometry.padding * 2 implicitHeight: label.implicitHeight + Theme.geometry.padding - radius: Theme.geometry.radius + radius: Theme.geometry.radiusSmall color: filled ? (mouseArea.pressed ? Qt.darker(tint, 1.1) : tint) : (mouseArea.containsMouse ? Qt.alpha(tint, 0.22) : Qt.alpha(tint, 0.15)) border.width: filled ? 0 : 1 border.color: Qt.alpha(tint, 0.3) + layer.enabled: filled + layer.effect: MultiEffect { + shadowEnabled: true + shadowColor: button.tint + shadowOpacity: 0.5 + shadowBlur: 0.6 + shadowVerticalOffset: 2 + } + Behavior on color { ColorAnimation { duration: Theme.animation.durationFast } } Behavior on scale { SpringAnimation { spring: 4; damping: 0.3 } } scale: mouseArea.pressed ? 0.97 : 1.0 diff --git a/mutable_config/quickshell/components/Shared/ContextMenu.qml b/mutable_config/quickshell/components/Shared/ContextMenu.qml index aa5340f..706b8ea 100644 --- a/mutable_config/quickshell/components/Shared/ContextMenu.qml +++ b/mutable_config/quickshell/components/Shared/ContextMenu.qml @@ -11,7 +11,7 @@ Rectangle { visible: false z: 1000 width: 180 - radius: 10 + radius: Theme.geometry.radiusMedium color: Theme.colors.background border.color: Theme.colors.border border.width: 1 @@ -43,7 +43,7 @@ Rectangle { delegate: Rectangle { width: column.width height: modelData.separator ? 1 : 28 - radius: modelData.separator ? 0 : 6 + radius: modelData.separator ? 0 : Theme.geometry.radiusTiny color: modelData.separator ? Theme.colors.border : (itemMouse.containsMouse ? Theme.colors.surfaceHover : "transparent") diff --git a/mutable_config/quickshell/components/Shared/Theme.qml b/mutable_config/quickshell/components/Shared/Theme.qml index a02bf6a..f0f37e8 100644 --- a/mutable_config/quickshell/components/Shared/Theme.qml +++ b/mutable_config/quickshell/components/Shared/Theme.qml @@ -4,27 +4,33 @@ import QtQuick QtObject { id: theme + // Regenerated by wallpaper-theme.nu on every wallpaper change - don't + // hand-edit between these markers, it gets overwritten. + // GENERATED:COLORS:BEGIN property QtObject colors: QtObject { - property color background: "#e611111b" // Opaque dark for better readability - property color surface: "#e6181825" + property color background: "#e611111b" + property color surface: "#cc181825" property color surfaceHover: "#f2313244" - property color overlay: "#6011111b" // Translucent dark for full screen dim - - property color primary: "#89b4fa" + property color overlay: "#6011111b" + + property color primary: "#74c7ec" property color secondary: "#b4befe" - property color accent: "#cba6f7" + property color accent: "#74c7ec" property color alert: "#f38ba8" property color success: "#a6e3a1" property color warning: "#f9e2af" - + property color text: "#cdd6f4" property color textMuted: "#a6adc8" - - property color border: "#30ffffff" + + property color border: "#1a74c7ec" } + // GENERATED:COLORS:END property QtObject geometry: QtObject { - property int radius: 16 + property int radiusTiny: 6 + property int radiusSmall: 8 + property int radiusMedium: 10 property int pillRadius: 100 property int padding: 12 property int spacing: 8 @@ -37,6 +43,6 @@ QtObject { } property QtObject font: QtObject { - property string family: "Inter" + property string family: "JetBrainsMono Nerd Font" } } diff --git a/mutable_config/quickshell/components/WallpaperPicker/WallpaperPicker.qml b/mutable_config/quickshell/components/WallpaperPicker/WallpaperPicker.qml new file mode 100644 index 0000000..4e6f1c0 --- /dev/null +++ b/mutable_config/quickshell/components/WallpaperPicker/WallpaperPicker.qml @@ -0,0 +1,198 @@ +import QtQuick +import Quickshell +import Quickshell.Wayland +import Quickshell.Io +import "../Shared" + +PanelWindow { + id: pickerWindow + property QtObject rootState + property var wallpapers: [] + property int currentIndex: 0 + property string currentWallpaperPath: "" + + readonly property string scriptPath: Quickshell.env("HOME") + "/.dotfiles/config/nushell/scripts/wallpaper-switch.nu" + + visible: rootState.wallpaperPickerOpen + + anchors { + top: true + bottom: true + left: true + right: true + } + + exclusiveZone: 0 + color: "transparent" + + WlrLayershell.layer: WlrLayer.Overlay + WlrLayershell.namespace: "quickshell-wallpaper-picker" + WlrLayershell.keyboardFocus: WlrKeyboardFocus.Exclusive + + Process { + id: listProcess + command: ["nu", pickerWindow.scriptPath, "--list-with-current"] + running: false + stdout: StdioCollector { + onStreamFinished: { + try { + let data = JSON.parse(this.text); + pickerWindow.wallpapers = data.wallpapers ?? []; + pickerWindow.currentWallpaperPath = data.current ?? ""; + } catch (e) { + pickerWindow.wallpapers = []; + pickerWindow.currentWallpaperPath = ""; + } + pickerWindow.selectInitialIndex(); + } + } + } + + Process { + id: applyProcess + running: false + } + + function wrappedIndex(i) { + let len = wallpapers.length; + return len > 0 ? ((i % len) + len) % len : 0; + } + + function selectInitialIndex() { + if (wallpapers.length === 0) return; + let idx = currentWallpaperPath.length > 0 + ? wallpapers.findIndex(w => w.path === currentWallpaperPath) + : -1; + currentIndex = idx >= 0 ? idx : 0; + } + + function applySelection() { + if (wallpapers.length === 0) return; + applyProcess.command = ["nu", pickerWindow.scriptPath, "--set", wallpapers[currentIndex].path]; + applyProcess.running = true; + rootState.wallpaperPickerOpen = false; + } + + onVisibleChanged: { + if (visible) { + listProcess.running = true; + } + } + + MouseArea { + anchors.fill: parent + onClicked: rootState.wallpaperPickerOpen = false + } + + Rectangle { + anchors.fill: parent + color: Theme.colors.overlay + + Behavior on opacity { NumberAnimation { duration: Theme.animation.durationNormal } } + opacity: pickerWindow.visible ? 1 : 0 + + MouseArea { + anchors.fill: parent + onClicked: rootState.wallpaperPickerOpen = false + } + + // Fixed slots, no sliding: only which wallpaper each slot shows changes. + Row { + id: carousel + anchors.centerIn: parent + spacing: Theme.geometry.spacing * 3 + + Repeater { + model: 5 + + delegate: Item { + id: delegateRoot + readonly property int offset: index - 2 + readonly property bool isCurrent: offset === 0 + readonly property int wpIndex: pickerWindow.wrappedIndex(pickerWindow.currentIndex + offset) + readonly property var wp: pickerWindow.wallpapers.length > 0 ? pickerWindow.wallpapers[wpIndex] : null + + width: isCurrent ? 260 : 170 + height: 340 + + Rectangle { + anchors.centerIn: parent + width: isCurrent ? 240 : 150 + height: isCurrent ? 320 : 200 + radius: Theme.geometry.radiusMedium + color: Theme.colors.surface + border.color: delegateRoot.isCurrent ? Theme.colors.primary : Theme.colors.border + border.width: delegateRoot.isCurrent ? 2 : 1 + opacity: delegateRoot.isCurrent ? 1.0 : 0.5 + clip: true + + Image { + anchors.fill: parent + anchors.margins: 4 + source: delegateRoot.wp ? "file://" + delegateRoot.wp.thumb : "" + fillMode: Image.PreserveAspectCrop + asynchronous: true + cache: true + } + } + + MouseArea { + anchors.fill: parent + cursorShape: Qt.PointingHandCursor + onClicked: { + if (delegateRoot.isCurrent) { + pickerWindow.applySelection(); + } else { + pickerWindow.currentIndex = delegateRoot.wpIndex; + } + } + } + } + } + } + + Text { + anchors.top: carousel.bottom + anchors.topMargin: Theme.geometry.spacing * 2 + anchors.horizontalCenter: parent.horizontalCenter + text: pickerWindow.wallpapers.length > 0 + ? (pickerWindow.wallpapers[pickerWindow.currentIndex]?.path ?? "").split("/").pop() + : "No wallpapers found" + color: Theme.colors.text + font.family: Theme.font.family + } + } + + Item { + id: keyHandler + anchors.fill: parent + focus: true + + Connections { + target: pickerWindow + function onVisibleChanged() { + if (pickerWindow.visible) keyHandler.forceActiveFocus(); + } + } + + Keys.onEscapePressed: (event) => { + rootState.wallpaperPickerOpen = false; + event.accepted = true; + } + + Keys.onLeftPressed: (event) => { + pickerWindow.currentIndex = pickerWindow.wrappedIndex(pickerWindow.currentIndex - 1); + event.accepted = true; + } + + Keys.onRightPressed: (event) => { + pickerWindow.currentIndex = pickerWindow.wrappedIndex(pickerWindow.currentIndex + 1); + event.accepted = true; + } + + Keys.onReturnPressed: (event) => { + pickerWindow.applySelection(); + event.accepted = true; + } + } +} diff --git a/mutable_config/quickshell/core/Theme.qml b/mutable_config/quickshell/core/Theme.qml deleted file mode 100644 index 6f449c8..0000000 --- a/mutable_config/quickshell/core/Theme.qml +++ /dev/null @@ -1,36 +0,0 @@ -pragma Singleton -import QtQuick - -QtObject { - // Mocha-like palette - property color bg: "#1e1e2e" - property color bgAlt: "#313244" - property color fg: "#cdd6f4" - property color fgAlt: "#a6adc8" - property color primary: "#89b4fa" - property color accent: "#f38ba8" - property color transparent: "transparent" - - property int radius: 8 - property int padding: 8 - - // Legacy / Catppuccin Aliases for imported Widgets - property string fontFamily: "sans-serif" - property int fontPixelSize: 14 - - property color base: "#1e1e2e" - property color crust: "#11111b" - property color text: "#cdd6f4" - property color subtext0: "#a6adc8" - property color surface0: "#313244" - property color surface1: "#45475a" - property color overlay1: "#7f849c" - property color overlay2: "#9399b2" - property color green: "#a6e3a1" - property color mauve: "#cba6f7" - property color lavender: "#b4befe" - property color red: "#f38ba8" - - property font font: Qt.font({ family: fontFamily, pixelSize: fontPixelSize }) - property font fontBold: Qt.font({ family: fontFamily, pixelSize: fontPixelSize, bold: true }) -} diff --git a/mutable_config/quickshell/core/qmldir b/mutable_config/quickshell/core/qmldir deleted file mode 100644 index 54401b5..0000000 --- a/mutable_config/quickshell/core/qmldir +++ /dev/null @@ -1 +0,0 @@ -singleton Theme Theme.qml \ No newline at end of file diff --git a/mutable_config/quickshell/shell.qml b/mutable_config/quickshell/shell.qml index 371e381..7e2253b 100644 --- a/mutable_config/quickshell/shell.qml +++ b/mutable_config/quickshell/shell.qml @@ -9,6 +9,7 @@ import "components/Shared" import "components/LogoutMenu" import "components/ClipboardManager" import "components/Notifications" +import "components/WallpaperPicker" ShellRoot { id: root @@ -17,6 +18,7 @@ ShellRoot { property bool commandPaletteOpen: false property bool logoutMenuOpen: false property bool clipboardManagerOpen: false + property bool wallpaperPickerOpen: false IpcHandler { target: "commandPalette" @@ -61,6 +63,28 @@ ShellRoot { } } + IpcHandler { + target: "wallpaperSwitcher" + function open() { + wallpaperPickerOpen = !wallpaperPickerOpen; + if (wallpaperPickerOpen) { + commandPaletteOpen = false; + logoutMenuOpen = false; + clipboardManagerOpen = false; + } + } + function random() { + randomWallpaperProcess.running = false; + randomWallpaperProcess.running = true; + } + } + + Process { + id: randomWallpaperProcess + command: ["nu", Quickshell.env("HOME") + "/.dotfiles/config/nushell/scripts/wallpaper-switch.nu", "--random"] + running: false + } + TrayTooltip { id: trayTooltip } @@ -93,4 +117,9 @@ ShellRoot { Notifications { id: notifications } + + WallpaperPicker { + id: wallpaperPicker + rootState: root + } }