Compare commits
7 Commits
150959a8f1
...
f16d320bad
| Author | SHA1 | Date | |
|---|---|---|---|
| f16d320bad | |||
| 92975f67ef | |||
| 44ad6d7061 | |||
| 34b163b9e6 | |||
| 913bc63021 | |||
| c739eaebab | |||
| 65d73b4ffd |
@ -45,20 +45,47 @@ in {
|
||||
lightDefs = import ./schemes/${color.lightScheme}.nix;
|
||||
darkDefs = import ./schemes/${color.darkScheme}.nix;
|
||||
|
||||
mkLightColorAssignment = key: {${key} = lightDefs.${key};};
|
||||
mkDarkColorAssignment = key: {${key} = darkDefs.${key};};
|
||||
mkColorAssignment = defs: key: {${key} = defs.${key};};
|
||||
mkRgbColorAssignment = defs: key: {${key} = mylib.color.hexToRGB defs.${key};};
|
||||
mkRgbStringColorAssignment = defs: key: {${key} = mylib.color.hexToRGBString "," defs.${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 mkLightColorAssignment)
|
||||
lib.mergeAttrsList
|
||||
];
|
||||
modules.color = {
|
||||
light = lib.pipe colorKeys [
|
||||
(builtins.map (mkColorAssignment lightDefs))
|
||||
lib.mergeAttrsList
|
||||
];
|
||||
|
||||
modules.color.dark = lib.pipe colorKeys [
|
||||
(builtins.map mkDarkColorAssignment)
|
||||
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
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@ -62,4 +62,14 @@ 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";
|
||||
};
|
||||
}
|
||||
|
||||
@ -34,17 +34,14 @@ 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(239, 241, 245, 0.3)";
|
||||
bg = mkLiteral "rgba(${color.rgbString.light.base}, 0.3)";
|
||||
hl = mkLiteral "#${color.dark.lavender}";
|
||||
text = mkLiteral "#${color.dark.base}";
|
||||
trans = mkLiteral "rgba(255, 255, 255, 0)";
|
||||
trans = mkLiteral "rgba(0, 0, 0, 0)";
|
||||
};
|
||||
|
||||
"element-text,element-icon,mode-switcher" = {
|
||||
@ -121,7 +118,7 @@ in {
|
||||
margin = 0;
|
||||
background-color = mkLiteral "@trans";
|
||||
text-color = mkLiteral "@text";
|
||||
border-radius = 3;
|
||||
# border-radius = 3;
|
||||
};
|
||||
|
||||
"element-icon" = {
|
||||
|
||||
@ -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(239, 241, 245, 0.3);
|
||||
background-color: rgba(${color.rgbString.light.base}, 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.sapphire};}
|
||||
#workspaces button.active {background-color: #${color.dark.pink};}
|
||||
#pulseaudio {background-color: #${color.dark.maroon};}
|
||||
#network {background-color: #${color.dark.peach};}
|
||||
#cpu {background-color: #${color.dark.yellow};}
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
mylib,
|
||||
...
|
||||
}: let
|
||||
inherit (config.modules) zathura;
|
||||
inherit (config.modules) zathura color;
|
||||
in {
|
||||
options.modules.zathura = import ./options.nix {inherit lib mylib;};
|
||||
|
||||
@ -12,47 +12,56 @@ in {
|
||||
programs.zathura = {
|
||||
enable = true;
|
||||
|
||||
# TODO: Set database backend
|
||||
# TODO: Use color module
|
||||
options = {
|
||||
# Catppuccin Latte
|
||||
default-fg = "#4C4F69";
|
||||
default-bg = "#EFF1F5";
|
||||
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;
|
||||
|
||||
completion-bg = "#CCD0DA";
|
||||
completion-fg = "#4C4F69";
|
||||
completion-highlight-bg = "#575268";
|
||||
completion-highlight-fg = "#4C4F69";
|
||||
completion-group-bg = "#CCD0DA";
|
||||
completion-group-fg = "#1E66F5";
|
||||
# Colorscheme
|
||||
default-bg = "#${color.light.base}";
|
||||
default-fg = "#${color.light.text}";
|
||||
|
||||
statusbar-fg = "#4C4F69";
|
||||
statusbar-bg = "#CCD0DA";
|
||||
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)";
|
||||
|
||||
notification-bg = "#CCD0DA";
|
||||
notification-fg = "#4C4F69";
|
||||
notification-error-bg = "#CCD0DA";
|
||||
notification-error-fg = "#D20F39";
|
||||
notification-warning-bg = "#CCD0DA";
|
||||
notification-warning-fg = "#FAE3B0";
|
||||
statusbar-bg = "#${color.dark.lavender}";
|
||||
statusbar-fg = default-fg;
|
||||
|
||||
inputbar-fg = "#4C4F69";
|
||||
inputbar-bg = "#CCD0DA";
|
||||
inputbar-bg = statusbar-bg;
|
||||
inputbar-fg = statusbar-fg;
|
||||
|
||||
recolor-lightcolor = "#EFF1F5";
|
||||
recolor-darkcolor = "#4C4F69";
|
||||
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;
|
||||
|
||||
index-fg = "#4C4F69";
|
||||
index-bg = "#EFF1F5";
|
||||
index-active-fg = "#4C4F69";
|
||||
index-active-bg = "#CCD0DA";
|
||||
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}";
|
||||
|
||||
render-loading-bg = "#EFF1F5";
|
||||
render-loading-fg = "#4C4F69";
|
||||
recolor-lightcolor = default-bg;
|
||||
recolor-darkcolor = default-fg;
|
||||
|
||||
highlight-color = "#575268";
|
||||
highlight-fg = "#EA76CB";
|
||||
highlight-active-color = "#EA76CB";
|
||||
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;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
133
lib/color.nix
Normal file
133
lib/color.nix
Normal file
@ -0,0 +1,133 @@
|
||||
{
|
||||
inputs,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
# This code was blatantly stolen from here:
|
||||
# https://github.com/Misterio77/nix-colors/blob/b92df8f5eb1fa20d8e09810c03c9dc0d94ef2820/lib/core/conversions.nix#L87
|
||||
hexToDecMap = {
|
||||
"0" = 0;
|
||||
"1" = 1;
|
||||
"2" = 2;
|
||||
"3" = 3;
|
||||
"4" = 4;
|
||||
"5" = 5;
|
||||
"6" = 6;
|
||||
"7" = 7;
|
||||
"8" = 8;
|
||||
"9" = 9;
|
||||
"a" = 10;
|
||||
"b" = 11;
|
||||
"c" = 12;
|
||||
"d" = 13;
|
||||
"e" = 14;
|
||||
"f" = 15;
|
||||
};
|
||||
|
||||
pow = base: exponent: let
|
||||
inherit (lib) mod;
|
||||
in
|
||||
if exponent > 1
|
||||
then let
|
||||
x = pow base (exponent / 2);
|
||||
odd_exp = mod exponent 2 == 1;
|
||||
in
|
||||
x
|
||||
* x
|
||||
* (
|
||||
if odd_exp
|
||||
then base
|
||||
else 1
|
||||
)
|
||||
else if exponent == 1
|
||||
then base
|
||||
else if exponent == 0 && base == 0
|
||||
then throw "undefined"
|
||||
else if exponent == 0
|
||||
then 1
|
||||
else throw "undefined";
|
||||
|
||||
base16To10 = exponent: scalar: scalar * (pow 16 exponent);
|
||||
|
||||
hexCharToDec = hex: let
|
||||
inherit (lib) toLower;
|
||||
lowerHex = toLower hex;
|
||||
in
|
||||
if builtins.stringLength hex != 1
|
||||
then throw "Function only accepts a single character."
|
||||
else if hexToDecMap ? ${lowerHex}
|
||||
then hexToDecMap."${lowerHex}"
|
||||
else throw "Character ${hex} is not a hexadecimal value.";
|
||||
in rec {
|
||||
/*
|
||||
Converts from hexadecimal to decimal.
|
||||
|
||||
Type: hexToDec :: string -> int
|
||||
|
||||
Args:
|
||||
hex: A hexadecimal string.
|
||||
|
||||
Example:
|
||||
hexadecimal "12"
|
||||
=> 18
|
||||
hexadecimal "FF"
|
||||
=> 255
|
||||
hexadecimal "abcdef"
|
||||
=> 11259375
|
||||
*/
|
||||
hexToDec = hex: let
|
||||
inherit (lib) stringToCharacters reverseList imap0 foldl;
|
||||
decimals = builtins.map hexCharToDec (stringToCharacters hex);
|
||||
decimalsAscending = reverseList decimals;
|
||||
decimalsPowered = imap0 base16To10 decimalsAscending;
|
||||
in
|
||||
foldl builtins.add 0 decimalsPowered;
|
||||
|
||||
/*
|
||||
Converts a 6 character hexadecimal string to RGB values.
|
||||
|
||||
Type: hexToRGB :: string => [int]
|
||||
|
||||
Args:
|
||||
hex: A hexadecimal string of length 6.
|
||||
|
||||
Example:
|
||||
hexToRGB "012345"
|
||||
=> [ 1 35 69 ]
|
||||
hexToRGB "abcdef"
|
||||
=> [171 205 239 ]
|
||||
hexToRGB "000FFF"
|
||||
=> [ 0 15 255 ]
|
||||
*/
|
||||
hexToRGB = hex: let
|
||||
rgbStartIndex = [0 2 4];
|
||||
hexList = builtins.map (x: builtins.substring x 2 hex) rgbStartIndex;
|
||||
hexLength = builtins.stringLength hex;
|
||||
in
|
||||
if hexLength != 6
|
||||
then
|
||||
throw ''
|
||||
Unsupported hex string length of ${builtins.toString hexLength}.
|
||||
Length must be exactly 6.
|
||||
''
|
||||
else builtins.map hexToDec hexList;
|
||||
|
||||
/*
|
||||
Converts a 6 character hexadecimal string to an RGB string seperated by a
|
||||
delimiter.
|
||||
|
||||
Type: hexToRGBString :: string -> string
|
||||
|
||||
Args:
|
||||
sep: The delimiter or seperator.
|
||||
hex: A hexadecimal string of length 6.
|
||||
*/
|
||||
hexToRGBString = sep: hex: let
|
||||
inherit (builtins) map toString;
|
||||
inherit (lib) concatStringsSep;
|
||||
hexInRGB = hexToRGB hex;
|
||||
hexInRGBString = map toString hexInRGB;
|
||||
in
|
||||
concatStringsSep sep hexInRGBString;
|
||||
}
|
||||
@ -12,4 +12,5 @@
|
||||
networking = import ./networking.nix {inherit inputs pkgs lib;};
|
||||
rofi = import ./rofi.nix {inherit inputs pkgs lib;};
|
||||
generators = import ./generators.nix {inherit inputs pkgs lib;};
|
||||
color = import ./color.nix {inherit inputs pkgs lib;};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user