Wallpaper: Add support for predefined styles.

This commit is contained in:
Dmitry Voronin 2024-12-28 11:22:38 +03:00
parent b783cf0d86
commit 3565544f46
Signed by: voronind
SSH key fingerprint: SHA256:3kBb4iV2ahufEBNq+vFbUe4QYfHt98DHQjN7QaptY9k
2 changed files with 49 additions and 36 deletions

View file

@ -1,9 +1,13 @@
# Download the wallpaper here. # Download the wallpaper here.
{ pkgs, lib, ... }: { pkgs, lib, ... }:
let let
url = "https://i.imgur.com/03KK4WG.jpeg"; url = "https://i.imgur.com/AKsJ3Rl.jpeg";
sha256 = "sha256-lCaYGl+Y1iLtslDqAu/HTqpyWgSOnR+bMI0fKSwjW6w="; sha256 = "sha256-DIgboGiIGJb2bKi7zqb17m7jctEgWyrSI/mSypeV7dQ=";
forceContrastText = false; forceContrastText = false;
# SEE: https://github.com/tinted-theming/schemes
# Warm: "${pkgs.base16-schemes}/share/themes/gruvbox-dark-hard.yaml"
style = null;
in in
{ {
options.module.wallpaper = { options.module.wallpaper = {
@ -15,5 +19,9 @@ in
default = pkgs.fetchurl { inherit url sha256; }; default = pkgs.fetchurl { inherit url sha256; };
type = lib.types.path; type = lib.types.path;
}; };
style = lib.mkOption {
default = style;
type = with lib.types; nullOr (oneOf [ path lines attrs ]);
};
}; };
} }

View file

@ -1,41 +1,46 @@
{ config, ... }: { config, lib, ... }:
let let
style = config.module.style; style = config.module.style;
wallpaper = config.module.wallpaper; wallpaper = config.module.wallpaper;
in in
{ {
stylix = { config = lib.mkMerge [
inherit (config.module.style) cursor; {
enable = true; stylix = {
autoEnable = true; inherit (config.module.style) cursor;
image = wallpaper.path; enable = true;
polarity = "dark"; autoEnable = true;
fonts = with style.font; { image = wallpaper.path;
inherit polarity = "dark";
emoji fonts = with style.font; {
monospace inherit
sansSerif emoji
serif monospace
; sansSerif
sizes = with size; { serif
inherit desktop terminal; ;
applications = application; sizes = with size; {
popups = popup; inherit desktop terminal;
applications = application;
popups = popup;
};
};
opacity = with style.opacity; {
inherit desktop terminal;
applications = application;
popups = popups;
};
}; };
}; }
opacity = with style.opacity; {
inherit desktop terminal; (lib.mkIf wallpaper.forceContrastText {
applications = application; stylix.override = {
popups = popups; base04 = lib.mkForce "000000";
}; base05 = lib.mkForce "ffffff";
override = base06 = lib.mkForce "ffffff";
if wallpaper.forceContrastText then };
{ })
base04 = "000000";
base05 = "ffffff"; (lib.mkIf (wallpaper.style != null) { stylix.base16Scheme = wallpaper.style; })
base06 = "ffffff"; ];
}
else
{ };
};
} }