1
Fork 0
satellite/modules/common/theming.nix

70 lines
2.4 KiB
Nix
Raw Permalink Normal View History

# Additional theming primitives not provided by stylix
{ lib, config, ... }:
let cfg = config.satellite.theming;
in
{
options.satellite.theming = {
2023-08-19 21:31:22 +02:00
rounding = {
2024-05-01 17:51:24 +02:00
# Note: this is automatically set to true when the radius is strictly positive
2023-08-19 21:31:22 +02:00
enable = lib.mkEnableOption "rounded corners for desktop apps";
2024-07-26 20:18:26 +02:00
radius = lib.mkOption { default = 0; type = lib.types.int; };
2023-08-19 21:31:22 +02:00
};
2024-05-01 17:51:24 +02:00
# These pretty much directly map onto hypland options
blur = {
# Note: this is automatically set to true when the passes are strictly positive
enable = lib.mkEnableOption "blurred backgrounds for desktop apps";
passes = lib.mkOption { default = 4; type = lib.types.int; };
brightness = lib.mkOption { default = 1.0; type = lib.types.float; };
contrast = lib.mkOption { default = 1.2; type = lib.types.float; };
2024-07-26 20:18:26 +02:00
size = lib.mkOption { default = 10; type = lib.types.int; };
2024-05-01 17:51:24 +02:00
};
2023-08-19 21:31:22 +02:00
get = lib.mkOption {
# No generics:(
# The type of this is essentially (written in ts-like -pseudocode):
#
# Record<String, T>
# & { default?: T | {light?: T, dark?: T } }
# -> Option<T>
type = lib.types.functionTo lib.types.anything;
description = "Index a theme map by the current theme";
};
colors = {
rgb = lib.mkOption {
type = lib.types.functionTo lib.types.str;
description = "Returns comma separated rgb values for a color. To be used in css files:)";
};
rgba = lib.mkOption {
type = lib.types.functionTo lib.types.str;
description = ''
Returns comma separated rgba values for a color.
The transparency is taken from `options.satellite.theming.transparency`.
'';
};
};
};
config.satellite.theming = {
2024-07-26 20:18:26 +02:00
rounding.enable = cfg.rounding.radius > 0;
2024-05-01 17:51:24 +02:00
blur.enable = cfg.blur.passes > 0;
get = themeMap:
themeMap.${config.lib.stylix.scheme.scheme}
or themeMap.default.${config.stylix.polarity or "dark"}
or themeMap.default
or (throw "Theme ${config.lib.stylix.scheme.scheme} not found in theme map!");
colors.rgb = color: builtins.concatStringsSep "," [
config.lib.stylix.scheme."${color}-rgb-r"
config.lib.stylix.scheme."${color}-rgb-g"
config.lib.stylix.scheme."${color}-rgb-b"
];
colors.rgba = color: "${cfg.colors.rgb color},${toString config.stylix.opacity.applications}";
};
}