From a67029abe7aa9cc1eeb86ea313ce49e9e4644cae Mon Sep 17 00:00:00 2001 From: Christoph Urlacher Date: Sun, 20 Jul 2025 15:17:53 +0200 Subject: [PATCH] Modules/Color: Move wallpaper selection from hyprland module to color module --- home/christoph/default.nix | 7 +- home/modules/color/default.nix | 21 ++++-- home/modules/color/options.nix | 101 ++++++++++++++++---------- home/modules/hyprland/default.nix | 6 +- home/modules/hyprland/options.nix | 25 ------- wallpapers/Ahsoka-Lo-Fi.jpg | 3 + wallpapers/Blade-Runner-Downwards.jpg | 4 +- wallpapers/Blade-Runner-Upwards.jpg | 4 +- wallpapers/City-Above.jpg | 3 + wallpapers/Control-Bureau.jpg | 3 + wallpapers/Lake-Fantasy.jpg | 3 + wallpapers/Minimal-Sunset.jpg | 3 + wallpapers/NASA.jpg | 3 + wallpapers/Night-City.jpg | 3 + wallpapers/Overshadowed.jpg | 3 + wallpapers/Punk.jpg | 3 + wallpapers/Rocket-Sunset.jpg | 3 + wallpapers/Windows.jpg | 3 + 18 files changed, 121 insertions(+), 80 deletions(-) create mode 100644 wallpapers/Ahsoka-Lo-Fi.jpg create mode 100644 wallpapers/City-Above.jpg create mode 100644 wallpapers/Control-Bureau.jpg create mode 100644 wallpapers/Lake-Fantasy.jpg create mode 100644 wallpapers/Minimal-Sunset.jpg create mode 100644 wallpapers/NASA.jpg create mode 100644 wallpapers/Night-City.jpg create mode 100644 wallpapers/Overshadowed.jpg create mode 100644 wallpapers/Punk.jpg create mode 100644 wallpapers/Rocket-Sunset.jpg create mode 100644 wallpapers/Windows.jpg diff --git a/home/christoph/default.nix b/home/christoph/default.nix index 1f42cd17..d56e5d44 100644 --- a/home/christoph/default.nix +++ b/home/christoph/default.nix @@ -54,11 +54,11 @@ color = { scheme = "catppuccin-mocha"; font = builtins.head nixosConfig.fonts.fontconfig.defaultFonts.monospace; + wallpaper = "Windows"; - bg = "base"; - text = "text"; accent = "mauve"; - accentHL = "pink"; + accentHl = "pink"; + accentDim = "lavender"; accentText = "base"; }; @@ -84,7 +84,6 @@ hyprland = { enable = !headless; dunst.enable = !config.modules.hyprpanel.enable; # Disable for hyprpanel - wallpaper = "City-Outlook"; keybindings = { main-mod = "SUPER"; diff --git a/home/modules/color/default.nix b/home/modules/color/default.nix index 2492fb01..92a53b86 100644 --- a/home/modules/color/default.nix +++ b/home/modules/color/default.nix @@ -63,17 +63,24 @@ in { colorDefs = scheme // { - bg = scheme.${color.bg}; - text = scheme.${color.text}; accent = scheme.${color.accent}; - accentHL = scheme.${color.accentHL}; + accentHl = scheme.${color.accentHl}; + accentDim = scheme.${color.accentDim}; accentText = scheme.${color.accentText}; }; - mkColorAssignment = key: {${key} = colorDefs.${key};}; - mkStringColorAssignment = key: {${key} = "#${colorDefs.${key}}";}; - mkRgbColorAssignment = key: {${key} = mylib.color.hexToRGB colorDefs.${key};}; - mkRgbStringColorAssignment = key: {${key} = mylib.color.hexToRGBString "," colorDefs.${key};}; + mkColorAssignment = key: { + ${key} = colorDefs.${key}; + }; + mkStringColorAssignment = key: { + ${key} = "#${colorDefs.${key}}"; + }; + mkRgbColorAssignment = key: { + ${key} = mylib.color.hexToRGB colorDefs.${key}; + }; + mkRgbStringColorAssignment = key: { + ${key} = mylib.color.hexToRGBString "," colorDefs.${key}; + }; in { # RRGGBB (0-F) hex = diff --git a/home/modules/color/options.nix b/home/modules/color/options.nix index 2d1f4bd5..ec29298a 100644 --- a/home/modules/color/options.nix +++ b/home/modules/color/options.nix @@ -32,7 +32,7 @@ "mantle" "crust" ]; -in { +in rec { scheme = lib.mkOption { type = lib.types.enum [ "catppuccin-latte" @@ -50,6 +50,69 @@ in { default = "JetBrainsMono Nerd Font Mono"; }; + # This option is set automatically + wallpapers = let + # Collect all the available wallpapers. + # We can't do this in default.nix as the value + # needs to be available during option evaluation. + wallpapers = let + rmFileExt = file: builtins.replaceStrings [".jpg"] [""] file; + + rmBasePath = file: let + matches = builtins.match "/.*/(.*)" file; + in + if matches == null + then file + else (builtins.head matches); + in + lib.filesystem.listFilesRecursive ../../../wallpapers + |> builtins.map builtins.toString + |> builtins.map rmFileExt + |> builtins.map rmBasePath; + in + lib.mkOption { + type = lib.types.listOf lib.types.str; + description = "The available wallpapers"; + default = wallpapers; + }; + + wallpaper = lib.mkOption { + type = lib.types.enum wallpapers.default; + description = "The wallpaper to use"; + example = "Foggy-Lake"; + default = "Foggy-Lake"; + }; + + # Some semantic aliases for colors + + accent = lib.mkOption { + type = lib.types.enum colorKeys; + description = "The accent color to use"; + example = "mauve"; + default = "mauve"; + }; + + accentHl = lib.mkOption { + type = lib.types.enum colorKeys; + description = "The accented accent color to use"; + example = "pink"; + default = "pink"; + }; + + accentDim = lib.mkOption { + type = lib.types.enum colorKeys; + description = "The dim accent color to use"; + example = "lavender"; + default = "lavender"; + }; + + accentText = lib.mkOption { + type = lib.types.enum colorKeys; + description = "The text color to use for accents"; + example = "base"; + default = "base"; + }; + # These options will be populated automatically. hex = lib.mkOption { @@ -71,40 +134,4 @@ in { type = lib.types.attrs; description = "Colors in \"RR,GG,BB\" decimal format"; }; - - # Some semantic aliases for colors - bg = lib.mkOption { - type = lib.types.enum colorKeys; - description = "The color to use as background"; - example = "base"; - default = "base"; - }; - - text = lib.mkOption { - type = lib.types.enum colorKeys; - description = "The text color to use"; - example = "text"; - default = "text"; - }; - - accent = lib.mkOption { - type = lib.types.enum colorKeys; - description = "The accent color to use"; - example = "mauve"; - default = "mauve"; - }; - - accentHL = lib.mkOption { - type = lib.types.enum colorKeys; - description = "The accented accent color to use"; - example = "pink"; - default = "pink"; - }; - - accentText = lib.mkOption { - type = lib.types.enum colorKeys; - description = "The text color to use for accents"; - example = "base"; - default = "base"; - }; } diff --git a/home/modules/hyprland/default.nix b/home/modules/hyprland/default.nix index 3c51251e..8a6651a0 100644 --- a/home/modules/hyprland/default.nix +++ b/home/modules/hyprland/default.nix @@ -235,7 +235,7 @@ in { background = [ { - path = "${config.paths.nixflake}/wallpapers/${hyprland.wallpaper}.jpg"; + path = "${config.paths.nixflake}/wallpapers/${color.wallpaper}.jpg"; blur_passes = 3; blur_size = 10; monitor = ""; @@ -305,12 +305,12 @@ in { preload = let mkPreload = name: "${config.paths.nixflake}/wallpapers/${name}.jpg"; in - hyprland.wallpapers |> builtins.map mkPreload; + color.wallpapers |> builtins.map mkPreload; wallpaper = let mkWallpaper = monitor: "${monitor}, " - + "${config.paths.nixflake}/wallpapers/${hyprland.wallpaper}.jpg"; + + "${config.paths.nixflake}/wallpapers/${color.wallpaper}.jpg"; in hyprland.monitors |> builtins.attrNames diff --git a/home/modules/hyprland/options.nix b/home/modules/hyprland/options.nix index 0a996d41..8e403d4c 100644 --- a/home/modules/hyprland/options.nix +++ b/home/modules/hyprland/options.nix @@ -17,31 +17,6 @@ description = "Keyboard layout variant"; }; - # A bit dumb, but I want a single location where those are defined. - # Only supposed to be set from here. - wallpapers = lib.mkOption { - type = lib.types.listOf lib.types.str; - description = "Available wallpapers"; - - # Run eza -1 | sd ".jpg" "" | sd "^" "\"" | sd "\$" "\"" | sd "\"\"" "" | wl-copy - # in ~/NixFlake/wallpapers/ - default = [ - "Blade-Runner-Downwards" - "Blade-Runner-Upwards" - "City-Outlook" - "Everest-Fishing" - "Foggy-Lake" - "Three-Bears" - ]; - }; - - wallpaper = lib.mkOption { - type = lib.types.enum wallpapers.default; - example = "Three-Bears"; - description = "Wallpaper to use"; - default = "Foggy-Lake"; - }; - dunst.enable = lib.mkEnableOption "Enable dunst notification daemon"; monitors = lib.mkOption { diff --git a/wallpapers/Ahsoka-Lo-Fi.jpg b/wallpapers/Ahsoka-Lo-Fi.jpg new file mode 100644 index 00000000..a798b0f6 --- /dev/null +++ b/wallpapers/Ahsoka-Lo-Fi.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:20ed91a33aaea45f153632488656951146991f10fb9abfcb91d2e6a09addb517 +size 1151442 diff --git a/wallpapers/Blade-Runner-Downwards.jpg b/wallpapers/Blade-Runner-Downwards.jpg index 54a91a3a..11e5c48f 100644 --- a/wallpapers/Blade-Runner-Downwards.jpg +++ b/wallpapers/Blade-Runner-Downwards.jpg @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a3a5ab0dfe0e127862573ed244df83abc448304300fa4b9bc582af10fdb268fe -size 1689425 +oid sha256:0f68cbca2453bcc87dd6547ddcd5a06ab2910765106d6c58c2cc7e3fcbfe77eb +size 1297944 diff --git a/wallpapers/Blade-Runner-Upwards.jpg b/wallpapers/Blade-Runner-Upwards.jpg index 25ef0678..6c5a704e 100644 --- a/wallpapers/Blade-Runner-Upwards.jpg +++ b/wallpapers/Blade-Runner-Upwards.jpg @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:195d42336d16a4a911d74e6fe41468b28d70b76e0d7b9ddc26237307cc2d7f51 -size 2964443 +oid sha256:73837006841dbb93af444fde9652acfa41be2b5446545d5623d03b16ebddd450 +size 2744036 diff --git a/wallpapers/City-Above.jpg b/wallpapers/City-Above.jpg new file mode 100644 index 00000000..887cf743 --- /dev/null +++ b/wallpapers/City-Above.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:36cded20eda0e2301d2673d0099e143cbdc9c9d97ed8d8f308e26ae2693bb23f +size 1224453 diff --git a/wallpapers/Control-Bureau.jpg b/wallpapers/Control-Bureau.jpg new file mode 100644 index 00000000..4f5ff35f --- /dev/null +++ b/wallpapers/Control-Bureau.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:892a9c274b6357a12a30a2ac08e866abafc49beb2403178e4667b2554c41ee61 +size 1481858 diff --git a/wallpapers/Lake-Fantasy.jpg b/wallpapers/Lake-Fantasy.jpg new file mode 100644 index 00000000..aaaa4312 --- /dev/null +++ b/wallpapers/Lake-Fantasy.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e277c1759255eb8f5ec9990b5e3f85988b5b8f3a18c4e794d75bed24305844ef +size 1363229 diff --git a/wallpapers/Minimal-Sunset.jpg b/wallpapers/Minimal-Sunset.jpg new file mode 100644 index 00000000..0a4f36e7 --- /dev/null +++ b/wallpapers/Minimal-Sunset.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:70f3d6fda31cc6c3ae3ac0c01b3bc2bb2ba66dad7e0978a6fa480e6834b505a5 +size 481814 diff --git a/wallpapers/NASA.jpg b/wallpapers/NASA.jpg new file mode 100644 index 00000000..7076e8e1 --- /dev/null +++ b/wallpapers/NASA.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7f752bb06aa2cb3c0f628ef28319685fbf208e8d3d840724aa4b1fe456f9a06d +size 149623 diff --git a/wallpapers/Night-City.jpg b/wallpapers/Night-City.jpg new file mode 100644 index 00000000..b69b746a --- /dev/null +++ b/wallpapers/Night-City.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5b677428398f490b916440ea792ff94ce47ad2e7413b63d1ad6207f70af46e41 +size 1437924 diff --git a/wallpapers/Overshadowed.jpg b/wallpapers/Overshadowed.jpg new file mode 100644 index 00000000..318b04bd --- /dev/null +++ b/wallpapers/Overshadowed.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:131ef231a8e7ac4b0aa745c7d0b42bdbc939df8120c01309ed88d091068026da +size 2124571 diff --git a/wallpapers/Punk.jpg b/wallpapers/Punk.jpg new file mode 100644 index 00000000..4ecec40d --- /dev/null +++ b/wallpapers/Punk.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2f054ddc29865bf226fa76fe1ed7dbc3e26bb524617e2867e69a7671a73210f6 +size 1481266 diff --git a/wallpapers/Rocket-Sunset.jpg b/wallpapers/Rocket-Sunset.jpg new file mode 100644 index 00000000..c62347fd --- /dev/null +++ b/wallpapers/Rocket-Sunset.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0c606a24ac34f9a3dd33713222e8ef2a9dbaa9c1b0f44473a96e2b57af999e9e +size 480357 diff --git a/wallpapers/Windows.jpg b/wallpapers/Windows.jpg new file mode 100644 index 00000000..74c2d19a --- /dev/null +++ b/wallpapers/Windows.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4303d3d454a83d98197297b7e9281de23dbfbaa16830ce99d62cc3b4b4f9d814 +size 1096425