diff --git a/modules/options/style/colors.nix b/modules/options/style/colors.nix index fe51a2c..bb2712c 100644 --- a/modules/options/style/colors.nix +++ b/modules/options/style/colors.nix @@ -1,28 +1,31 @@ # NOTE: This module is entirely inspired by raf, # most of the nix code is also taken from him, # so please do check out his configuration! +# raf himself took it from misterio77 +# and adapted it for his personal use, +# so look there too. +# { config, lib, ... }: let - inherit (lib) mkOptionType isString mkOption; - inherit (lib.strings) replaceStrings hasPrefix removePrefix toLower; - inherit (lib.types) enum str coercedTo nullOr attrsOf; + inherit (lib.options) mkOption literalExpression; + inherit (lib.types) str nullOr enum mkOptionType attrsOf coercedTo; + inherit (lib.strings) toLower replaceStrings removePrefix hasPrefix isString; + # inherit (lib) serializeTheme; cfg = config.modules.style; - nameToSlug = name: toLower (replaceStrings [" "] ["-"] name); - hexColorType = mkOptionType { name = "hex-color"; descriptionClass = "noun"; description = "RGB color in hex format"; check = x: isString x && !(hasPrefix "#" x); }; - colorType = attrsOf (coercedTo str (removePrefix "#") hexColorType); + nameToSlug = name: toLower (replaceStrings [" "] ["-"] name); getPaletteFromScheme = slug: if builtins.pathExists ./palettes/${slug}.nix then (import ./palettes/${slug}.nix).colorscheme.palette @@ -31,18 +34,64 @@ in { options.modules.style = { colorScheme = { name = mkOption { - type = nullOr (enum ["Catppuccin Mocha" "Catppuccin Latte"]); + type = nullOr (enum ["Catppuccin Mocha" "Tokyonight Storm" "Oxocarbon Dark"]); + description = "The colorscheme that should be used globally to theme your system."; default = "Catppuccin Mocha"; }; - slug = { + + slug = mkOption { type = str; - default = nameToSlug "${toString cfg.colorScheme.name}"; - }; - variant = { + default = nameToSlug "${toString cfg.colorScheme.name}"; # toString to avoid type errors if null, returns "" + description = '' + The serialized slug for the colorScheme you are using. + + Defaults to a lowercased version of the theme name with spaces + replaced with hyphens. + + Must only be changed if the slug is expected to be different than + the serialized theme name." + ''; }; + colors = mkOption { type = colorType; default = getPaletteFromScheme cfg.colorScheme.slug; + description = '' + An attribute set containing active colors of the system. Follows base16 + scheme by default but can be expanded to base24 or anything "above" as + seen fit as the module option is actually not checked in any way + ''; + example = literalExpression '' + { + base00 = "#1e1e2e"; # Base + base01 = "#181825"; # Mantle + base02 = "#313244"; # Surface0 + base03 = "#45475a"; # Surface1 + base04 = "#585b70"; # Surface2 + base05 = "#cdd6f4"; # text + base06 = "#f5e0dc"; # rosewater + base07 = "#b4befe"; # lavender + base08 = "#f38ba8"; # red + base09 = "#fab387"; # peach + base0A = "#a6e3a1"; # yellow + base0B = "#94e2d5"; # green + base0C = "#94e2d5"; # teal + base0D = "#89b4fa"; # blue + base0E = "#cba6f7"; # mauve + base0F = "#f2cdcd"; # flamingo + } + ''; + }; + + variant = mkOption { + type = enum ["dark" "light"]; + default = + if builtins.substring 0 1 cfg.colorScheme.colors.base00 < "5" + then "dark" + else "light"; + description = '' + Whether the scheme is dark or light + ''; }; }; }; diff --git a/modules/programs/gui/foot.nix b/modules/programs/gui/foot.nix index cc67a39..34486cc 100644 --- a/modules/programs/gui/foot.nix +++ b/modules/programs/gui/foot.nix @@ -7,6 +7,7 @@ }: let cfg = config.modules.system.programs.terminals.foot; inherit (config.modules.other.system) username; + inherit (config.modules.style.colorScheme) colors; inherit (lib) mkIf; in { @@ -73,6 +74,28 @@ in { hide-when-typing = "yes"; # not really needed since we already enable this in Hyprland. alternate-scroll-mode = "yes"; }; + colors = with colors; { + background = base00; # base color + foreground = base05; # text color + + regular0 = base03; # black + regular1 = base08; # red + regular2 = base0B; # green + regular3 = base0A; # yellow + regular4 = base0D; # blue + regular5 = base0F; #magenta + regular6 = base0C; #cyan + regular7 = base06; #white + + bright0 = base04; # Surface 2 + bright1 = base08; # red + bright2 = base0B; # green + bright3 = base0A; # yellow + bright4 = base0D; # blue + bright5 = base0F; # pink + bright6 = base0C; # teal + bright7 = base07; # Subtext 0 + }; }; }; }; diff --git a/modules/wms/wayland/hyprland/settings.nix b/modules/wms/wayland/hyprland/settings.nix index 7f31c42..82a4f2a 100644 --- a/modules/wms/wayland/hyprland/settings.nix +++ b/modules/wms/wayland/hyprland/settings.nix @@ -7,6 +7,7 @@ inherit (config.modules.system.hardware) monitors; inherit (lib) mapAttrsToList; inherit (builtins) toString; + inherit (config.modules.style.colorScheme) colors; in { home-manager.users.${username} = { wayland.windowManager.hyprland.settings = { @@ -50,6 +51,8 @@ in { gaps_out = 0; border_size = 2; + + "col.active_border" = "0xff${colors.base07}"; no_border_on_floating = true; };