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

View File

@ -62,14 +62,4 @@ in
type = types.attrs; type = types.attrs;
description = "Colors belonging to the selected dark scheme"; 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; sidebar-mode = false;
}; };
# bg-col: rgba(239, 241, 245, 60%);
theme = let theme = let
inherit (config.lib.formats.rasi) mkLiteral; inherit (config.lib.formats.rasi) mkLiteral;
mkColor = color: mkLiteral "#{color}";
in { in {
"*" = { "*" = {
bg = mkLiteral "rgba(${color.rgbString.light.base}, 0.3)"; bg = mkLiteral "rgba(239, 241, 245, 0.3)";
hl = mkLiteral "#${color.dark.lavender}"; hl = mkLiteral "#${color.dark.lavender}";
text = mkLiteral "#${color.dark.base}"; 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" = { "element-text,element-icon,mode-switcher" = {
@ -118,7 +121,7 @@ in {
margin = 0; margin = 0;
background-color = mkLiteral "@trans"; background-color = mkLiteral "@trans";
text-color = mkLiteral "@text"; text-color = mkLiteral "@text";
# border-radius = 3; border-radius = 3;
}; };
"element-icon" = { "element-icon" = {

View File

@ -97,7 +97,7 @@ in {
border-color: #${color.dark.lavender}; border-color: #${color.dark.lavender};
/*Can't use color.light.base here because waybar doesn't support rrggbbaa :(*/ /*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*/ /*Colors*/
@ -105,7 +105,7 @@ in {
#user {background-color: #${color.dark.pink};} #user {background-color: #${color.dark.pink};}
#window {background-color: #${color.dark.mauve};} #window {background-color: #${color.dark.mauve};}
#workspaces button {background-color: #${color.dark.lavender};} #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};} #pulseaudio {background-color: #${color.dark.maroon};}
#network {background-color: #${color.dark.peach};} #network {background-color: #${color.dark.peach};}
#cpu {background-color: #${color.dark.yellow};} #cpu {background-color: #${color.dark.yellow};}

View File

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

View File

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