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;
|
lightDefs = import ./schemes/${color.lightScheme}.nix;
|
||||||
darkDefs = import ./schemes/${color.darkScheme}.nix;
|
darkDefs = import ./schemes/${color.darkScheme}.nix;
|
||||||
|
|
||||||
mkLightColorAssignment = key: {${key} = lightDefs.${key};};
|
mkColorAssignment = defs: key: {${key} = defs.${key};};
|
||||||
mkDarkColorAssignment = key: {${key} = darkDefs.${key};};
|
mkRgbColorAssignment = defs: key: {${key} = mylib.color.hexToRGB defs.${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.light = lib.pipe colorKeys [
|
modules.color = {
|
||||||
(builtins.map mkLightColorAssignment)
|
light = lib.pipe colorKeys [
|
||||||
lib.mergeAttrsList
|
(builtins.map (mkColorAssignment lightDefs))
|
||||||
];
|
lib.mergeAttrsList
|
||||||
|
];
|
||||||
|
|
||||||
modules.color.dark = lib.pipe colorKeys [
|
dark = lib.pipe colorKeys [
|
||||||
(builtins.map mkDarkColorAssignment)
|
(builtins.map (mkColorAssignment darkDefs))
|
||||||
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
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -62,4 +62,14 @@ 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";
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,17 +34,14 @@ 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(239, 241, 245, 0.3)";
|
bg = mkLiteral "rgba(${color.rgbString.light.base}, 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(255, 255, 255, 0)";
|
trans = mkLiteral "rgba(0, 0, 0, 0)";
|
||||||
};
|
};
|
||||||
|
|
||||||
"element-text,element-icon,mode-switcher" = {
|
"element-text,element-icon,mode-switcher" = {
|
||||||
@ -121,7 +118,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" = {
|
||||||
|
|||||||
@ -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(239, 241, 245, 0.3);
|
background-color: rgba(${color.rgbString.light.base}, 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.sapphire};}
|
#workspaces button.active {background-color: #${color.dark.pink};}
|
||||||
#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};}
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
mylib,
|
mylib,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (config.modules) zathura;
|
inherit (config.modules) zathura color;
|
||||||
in {
|
in {
|
||||||
options.modules.zathura = import ./options.nix {inherit lib mylib;};
|
options.modules.zathura = import ./options.nix {inherit lib mylib;};
|
||||||
|
|
||||||
@ -12,47 +12,56 @@ in {
|
|||||||
programs.zathura = {
|
programs.zathura = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
||||||
# TODO: Set database backend
|
options = rec {
|
||||||
# TODO: Use color module
|
n-completion-items = 10;
|
||||||
options = {
|
font = "${color.font} 11";
|
||||||
# Catppuccin Latte
|
guioptions = "s"; # s - statusbar, c - command line
|
||||||
default-fg = "#4C4F69";
|
database = "sqlite";
|
||||||
default-bg = "#EFF1F5";
|
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";
|
# Colorscheme
|
||||||
completion-fg = "#4C4F69";
|
default-bg = "#${color.light.base}";
|
||||||
completion-highlight-bg = "#575268";
|
default-fg = "#${color.light.text}";
|
||||||
completion-highlight-fg = "#4C4F69";
|
|
||||||
completion-group-bg = "#CCD0DA";
|
|
||||||
completion-group-fg = "#1E66F5";
|
|
||||||
|
|
||||||
statusbar-fg = "#4C4F69";
|
highlight-color = "rgba(${color.rgbString.dark.lavender}, 0.5)";
|
||||||
statusbar-bg = "#CCD0DA";
|
highlight-fg = "rgba(${color.rgbString.dark.green}, 0.5)";
|
||||||
|
highlight-active-color = "rgba(${color.rgbString.dark.pink}, 0.5)";
|
||||||
|
|
||||||
notification-bg = "#CCD0DA";
|
statusbar-bg = "#${color.dark.lavender}";
|
||||||
notification-fg = "#4C4F69";
|
statusbar-fg = default-fg;
|
||||||
notification-error-bg = "#CCD0DA";
|
|
||||||
notification-error-fg = "#D20F39";
|
|
||||||
notification-warning-bg = "#CCD0DA";
|
|
||||||
notification-warning-fg = "#FAE3B0";
|
|
||||||
|
|
||||||
inputbar-fg = "#4C4F69";
|
inputbar-bg = statusbar-bg;
|
||||||
inputbar-bg = "#CCD0DA";
|
inputbar-fg = statusbar-fg;
|
||||||
|
|
||||||
recolor-lightcolor = "#EFF1F5";
|
completion-bg = "#${color.light.surface0}";
|
||||||
recolor-darkcolor = "#4C4F69";
|
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";
|
notification-bg = completion-bg;
|
||||||
index-bg = "#EFF1F5";
|
notification-fg = default-fg;
|
||||||
index-active-fg = "#4C4F69";
|
notification-warning-bg = notification-bg;
|
||||||
index-active-bg = "#CCD0DA";
|
notification-warning-fg = "#${color.light.peach}";
|
||||||
|
notification-error-bg = notification-bg;
|
||||||
|
notification-error-fg = "#${color.light.red}";
|
||||||
|
|
||||||
render-loading-bg = "#EFF1F5";
|
recolor-lightcolor = default-bg;
|
||||||
render-loading-fg = "#4C4F69";
|
recolor-darkcolor = default-fg;
|
||||||
|
|
||||||
highlight-color = "#575268";
|
index-bg = default-bg;
|
||||||
highlight-fg = "#EA76CB";
|
index-fg = default-fg;
|
||||||
highlight-active-color = "#EA76CB";
|
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;};
|
networking = import ./networking.nix {inherit inputs pkgs lib;};
|
||||||
rofi = import ./rofi.nix {inherit inputs pkgs lib;};
|
rofi = import ./rofi.nix {inherit inputs pkgs lib;};
|
||||||
generators = import ./generators.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