treewide: blur regreet wallpaper

This commit is contained in:
Anthony Rodriguez 2024-11-21 23:34:23 +01:00
parent 1561a2075e
commit 5cfbe69893
Signed by: nezia
GPG key ID: EE3BE97C040A86CE
2 changed files with 15 additions and 49 deletions

View file

@ -1,4 +1,4 @@
{lib, ...}: let let
# convert rrggbb hex to rgba(r, g, b, a) # convert rrggbb hex to rgba(r, g, b, a)
rgba = c: let rgba = c: let
r = toString (hexToDec (builtins.substring 0 2 c)); r = toString (hexToDec (builtins.substring 0 2 c));
@ -7,7 +7,7 @@
in "rgba(${r}, ${g}, ${b}, .5)"; in "rgba(${r}, ${g}, ${b}, .5)";
# Helper function to convert hex color to decimal RGB values # Helper function to convert hex color to decimal RGB values
hexToDec = v: let hexToDec = lib: v: let
hexToInt = { hexToInt = {
"0" = 0; "0" = 0;
"1" = 1; "1" = 1;
@ -38,52 +38,15 @@
(lib.imap (k: v: hexToInt."${v}" * (pow 16 (builtins.length chars - k - 1))) chars); (lib.imap (k: v: hexToInt."${v}" * (pow 16 (builtins.length chars - k - 1))) chars);
# Power function for exponentiation # 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 blurImage = pkgs: path:
colorToKde = name: hexColor: let pkgs.runCommand "${builtins.baseNameOf path}-blurred" {
r = hexToDec (builtins.substring 0 2 hexColor); buildInputs = [pkgs.imagemagick];
g = hexToDec (builtins.substring 2 2 hexColor); }
b = hexToDec (builtins.substring 4 2 hexColor); ''
in "[${name}]\nColor=${toString r},${toString g},${toString b}\n"; magick ${path} -gaussian-blur 0x12 "$out"
'';
# Mapping base16 colors to KDE color scheme sections in {
schemeToKonsole = scheme: let inherit blurImage rgba;
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);
in {
inherit mkKonsoleColorScheme rgba;
} }

View file

@ -2,10 +2,12 @@
inputs, inputs,
config, config,
lib, lib,
lib',
pkgs, pkgs,
... ...
}: let }: let
inherit (lib) getExe evalModules; inherit (lib) getExe evalModules;
inherit (lib') blurImage;
inherit (inputs) niri; inherit (inputs) niri;
in { in {
services.greetd = let services.greetd = let
@ -72,7 +74,8 @@ in {
}; };
settings = { settings = {
background = { background = {
path = config.theme.wallpaper; path = blurImage pkgs config.theme.wallpaper;
fit = "Fill"; fit = "Fill";
}; };
GTK = { GTK = {