From 5cfbe69893e4b90a207510b5d9c0a4191187896f Mon Sep 17 00:00:00 2001 From: Anthony Rodriguez Date: Thu, 21 Nov 2024 23:34:23 +0100 Subject: [PATCH] treewide: blur regreet wallpaper --- lib/default.nix | 59 +++++++------------------------------- system/services/greetd.nix | 5 +++- 2 files changed, 15 insertions(+), 49 deletions(-) diff --git a/lib/default.nix b/lib/default.nix index ad5a2dd..1d1f1fc 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -1,4 +1,4 @@ -{lib, ...}: let +let # convert rrggbb hex to rgba(r, g, b, a) rgba = c: let r = toString (hexToDec (builtins.substring 0 2 c)); @@ -7,7 +7,7 @@ in "rgba(${r}, ${g}, ${b}, .5)"; # Helper function to convert hex color to decimal RGB values - hexToDec = v: let + hexToDec = lib: v: let hexToInt = { "0" = 0; "1" = 1; @@ -38,52 +38,15 @@ (lib.imap (k: v: hexToInt."${v}" * (pow 16 (builtins.length chars - k - 1))) chars); # Power function for exponentiation - pow = base: exponent: lib.foldl' (acc: _: acc * base) 1 (lib.range 1 exponent); + pow = lib: base: exponent: lib.foldl' (acc: _: acc * base) 1 (lib.range 1 exponent); - # Converts hex color to KDE color format - colorToKde = name: hexColor: let - r = hexToDec (builtins.substring 0 2 hexColor); - g = hexToDec (builtins.substring 2 2 hexColor); - b = hexToDec (builtins.substring 4 2 hexColor); - in "[${name}]\nColor=${toString r},${toString g},${toString b}\n"; - - # Mapping base16 colors to KDE color scheme sections - schemeToKonsole = scheme: let - inherit (scheme) palette; - - colorMap = { - base00 = ["Background" "BackgroundFaint" "BackgroundIntense"]; - base01 = ["Color0"]; - base02 = ["Color0Intense"]; - base04 = ["Color4"]; - base05 = ["Foreground" "ForegroundFaint" "ForegroundIntense"]; - base06 = ["Color7"]; - base07 = ["Color7Intense"]; - base08 = ["Color1" "Color1Intense"]; - base09 = ["Color1Intense"]; - base0A = ["Color3" "Color3Intense"]; - base0B = ["Color2" "Color2Intense"]; - base0C = ["Color6" "Color6Intense"]; - base0D = ["Color4" "Color4Intense"]; - base0E = ["Color5" "Color5Intense"]; - }; - - colorSections = lib.concatStringsSep "\n" (lib.attrsets.mapAttrsToList - (name: value: - lib.concatMapStrings (slot: colorToKde slot value) (colorMap.${name} or [])) - palette); - in - lib.concatStringsSep "\n" [ - "[General]" - "Description=${scheme.name}" - "Opacity=1" - "Wallpaper=" - colorSections - ]; - - # Create a KDE konsole color scheme from base16 colors - mkKonsoleColorScheme = pkgs: scheme: - pkgs.writeText "${scheme.name}.colorscheme" (schemeToKonsole scheme); + blurImage = pkgs: path: + pkgs.runCommand "${builtins.baseNameOf path}-blurred" { + buildInputs = [pkgs.imagemagick]; + } + '' + magick ${path} -gaussian-blur 0x12 "$out" + ''; in { - inherit mkKonsoleColorScheme rgba; + inherit blurImage rgba; } diff --git a/system/services/greetd.nix b/system/services/greetd.nix index 27af996..79631b2 100644 --- a/system/services/greetd.nix +++ b/system/services/greetd.nix @@ -2,10 +2,12 @@ inputs, config, lib, + lib', pkgs, ... }: let inherit (lib) getExe evalModules; + inherit (lib') blurImage; inherit (inputs) niri; in { services.greetd = let @@ -72,7 +74,8 @@ in { }; settings = { background = { - path = config.theme.wallpaper; + path = blurImage pkgs config.theme.wallpaper; + fit = "Fill"; }; GTK = {