1

Compare commits

..

1 Commits

Author SHA1 Message Date
150959a8f1 Lib: Add color functions 2024-10-14 17:13:53 +02:00
6 changed files with 55 additions and 98 deletions

View File

@ -45,47 +45,20 @@ in {
lightDefs = import ./schemes/${color.lightScheme}.nix;
darkDefs = import ./schemes/${color.darkScheme}.nix;
mkColorAssignment = defs: key: {${key} = defs.${key};};
mkRgbColorAssignment = defs: key: {${key} = mylib.color.hexToRGB defs.${key};};
mkRgbStringColorAssignment = defs: key: {${key} = mylib.color.hexToRGBString "," defs.${key};};
mkLightColorAssignment = key: {${key} = lightDefs.${key};};
mkDarkColorAssignment = key: {${key} = darkDefs.${key};};
in
lib.mkIf color.enable {
# This module sets its own options
# to the values specified in a colorscheme file.
modules.color = {
light = lib.pipe colorKeys [
(builtins.map (mkColorAssignment lightDefs))
lib.mergeAttrsList
];
modules.color.light = lib.pipe colorKeys [
(builtins.map mkLightColorAssignment)
lib.mergeAttrsList
];
dark = lib.pipe colorKeys [
(builtins.map (mkColorAssignment darkDefs))
lib.mergeAttrsList
];
rgb = {
light = lib.pipe colorKeys [
(builtins.map (mkRgbColorAssignment lightDefs))
lib.mergeAttrsList
];
dark = lib.pipe colorKeys [
(builtins.map (mkRgbColorAssignment darkDefs))
lib.mergeAttrsList
];
};
rgbString = {
light = lib.pipe colorKeys [
(builtins.map (mkRgbStringColorAssignment lightDefs))
lib.mergeAttrsList
];
dark = lib.pipe colorKeys [
(builtins.map (mkRgbStringColorAssignment darkDefs))
lib.mergeAttrsList
];
};
};
modules.color.dark = lib.pipe colorKeys [
(builtins.map mkDarkColorAssignment)
lib.mergeAttrsList
];
};
}

View File

@ -62,14 +62,4 @@ in
type = types.attrs;
description = "Colors belonging to the selected dark scheme";
};
rgbString = mkOption {
type = types.attrs;
description = "Colors belonging to the selected light scheme in 'RR,GG,BB' format";
};
rgb = mkOption {
type = types.attrs;
description = "Colors belonging to the selected light scheme in '[RR GG BB]' format";
};
}

View File

@ -34,14 +34,17 @@ in {
sidebar-mode = false;
};
# bg-col: rgba(239, 241, 245, 60%);
theme = let
inherit (config.lib.formats.rasi) mkLiteral;
mkColor = color: mkLiteral "#{color}";
in {
"*" = {
bg = mkLiteral "rgba(${color.rgbString.light.base}, 0.3)";
bg = mkLiteral "rgba(239, 241, 245, 0.3)";
hl = mkLiteral "#${color.dark.lavender}";
text = mkLiteral "#${color.dark.base}";
trans = mkLiteral "rgba(0, 0, 0, 0)";
trans = mkLiteral "rgba(255, 255, 255, 0)";
};
"element-text,element-icon,mode-switcher" = {
@ -118,7 +121,7 @@ in {
margin = 0;
background-color = mkLiteral "@trans";
text-color = mkLiteral "@text";
# border-radius = 3;
border-radius = 3;
};
"element-icon" = {

View File

@ -97,7 +97,7 @@ in {
border-color: #${color.dark.lavender};
/*Can't use color.light.base here because waybar doesn't support rrggbbaa :(*/
background-color: rgba(${color.rgbString.light.base}, 0.3);
background-color: rgba(239, 241, 245, 0.3);
}
/*Colors*/
@ -105,7 +105,7 @@ in {
#user {background-color: #${color.dark.pink};}
#window {background-color: #${color.dark.mauve};}
#workspaces button {background-color: #${color.dark.lavender};}
#workspaces button.active {background-color: #${color.dark.pink};}
#workspaces button.active {background-color: #${color.dark.sapphire};}
#pulseaudio {background-color: #${color.dark.maroon};}
#network {background-color: #${color.dark.peach};}
#cpu {background-color: #${color.dark.yellow};}

View File

@ -4,7 +4,7 @@
mylib,
...
}: let
inherit (config.modules) zathura color;
inherit (config.modules) zathura;
in {
options.modules.zathura = import ./options.nix {inherit lib mylib;};
@ -12,56 +12,47 @@ in {
programs.zathura = {
enable = true;
options = rec {
n-completion-items = 10;
font = "${color.font} 11";
guioptions = "s"; # s - statusbar, c - command line
database = "sqlite";
adjust-open = "best-fit";
recolor-keephue = true;
statusbar-basename = true;
statusbar-home-tilde = true;
window-title-basename = statusbar-basename;
window-title-home-tilde = statusbar-home-tilde;
# TODO: Set database backend
# TODO: Use color module
options = {
# Catppuccin Latte
default-fg = "#4C4F69";
default-bg = "#EFF1F5";
# Colorscheme
default-bg = "#${color.light.base}";
default-fg = "#${color.light.text}";
completion-bg = "#CCD0DA";
completion-fg = "#4C4F69";
completion-highlight-bg = "#575268";
completion-highlight-fg = "#4C4F69";
completion-group-bg = "#CCD0DA";
completion-group-fg = "#1E66F5";
highlight-color = "rgba(${color.rgbString.dark.lavender}, 0.5)";
highlight-fg = "rgba(${color.rgbString.dark.green}, 0.5)";
highlight-active-color = "rgba(${color.rgbString.dark.pink}, 0.5)";
statusbar-fg = "#4C4F69";
statusbar-bg = "#CCD0DA";
statusbar-bg = "#${color.dark.lavender}";
statusbar-fg = default-fg;
notification-bg = "#CCD0DA";
notification-fg = "#4C4F69";
notification-error-bg = "#CCD0DA";
notification-error-fg = "#D20F39";
notification-warning-bg = "#CCD0DA";
notification-warning-fg = "#FAE3B0";
inputbar-bg = statusbar-bg;
inputbar-fg = statusbar-fg;
inputbar-fg = "#4C4F69";
inputbar-bg = "#CCD0DA";
completion-bg = "#${color.light.surface0}";
completion-fg = default-fg;
completion-highlight-bg = statusbar-bg;
completion-highlight-fg = completion-fg;
completion-group-bg = completion-bg;
completion-group-fg = completion-fg;
recolor-lightcolor = "#EFF1F5";
recolor-darkcolor = "#4C4F69";
notification-bg = completion-bg;
notification-fg = default-fg;
notification-warning-bg = notification-bg;
notification-warning-fg = "#${color.light.peach}";
notification-error-bg = notification-bg;
notification-error-fg = "#${color.light.red}";
index-fg = "#4C4F69";
index-bg = "#EFF1F5";
index-active-fg = "#4C4F69";
index-active-bg = "#CCD0DA";
recolor-lightcolor = default-bg;
recolor-darkcolor = default-fg;
render-loading-bg = "#EFF1F5";
render-loading-fg = "#4C4F69";
index-bg = default-bg;
index-fg = default-fg;
index-active-bg = completion-highlight-bg;
index-active-fg = completion-highlight-fg;
render-loading-bg = default-bg;
render-loading-fg = default-fg;
highlight-color = "#575268";
highlight-fg = "#EA76CB";
highlight-active-color = "#EA76CB";
};
};
};

View File

@ -26,7 +26,7 @@
};
pow = base: exponent: let
inherit (lib) mod;
inherit (nixpkgs-lib) mod;
in
if exponent > 1
then let
@ -51,7 +51,7 @@
base16To10 = exponent: scalar: scalar * (pow 16 exponent);
hexCharToDec = hex: let
inherit (lib) toLower;
inherit (nixpkgs-lib) toLower;
lowerHex = toLower hex;
in
if builtins.stringLength hex != 1
@ -125,7 +125,7 @@ in rec {
*/
hexToRGBString = sep: hex: let
inherit (builtins) map toString;
inherit (lib) concatStringsSep;
inherit (nixpkgs-lib) concatStringsSep;
hexInRGB = hexToRGB hex;
hexInRGBString = map toString hexInRGB;
in