Rework solarized

This commit is contained in:
Jakob Lechner 2025-10-24 17:38:34 +02:00
parent 0a2a569682
commit c9a956bc63
4 changed files with 186 additions and 171 deletions

View file

@ -1,9 +1,5 @@
builtins.mapAttrs let
(_: hex: { colors = {
inherit hex;
rgb = builtins.concatStringsSep "," (map (f: toString (builtins.fromTOML "i = 0x${f hex}").i) (map (pos: builtins.substring pos 2) [ 1 3 5 ]));
})
{
base00 = "#657b83"; base00 = "#657b83";
base01 = "#586e75"; base01 = "#586e75";
base02 = "#073642"; base02 = "#073642";
@ -20,4 +16,53 @@ builtins.mapAttrs
red = "#dc322f"; red = "#dc322f";
violet = "#6c71c4"; violet = "#6c71c4";
yellow = "#b58900"; yellow = "#b58900";
};
common = {
base08 = colors.red;
base09 = colors.orange;
base0A = colors.yellow;
base0B = colors.green;
base0C = colors.cyan;
base0D = colors.blue;
base0E = colors.violet;
base0F = colors.magenta;
};
light = common // {
base00 = colors.base3;
base01 = colors.base2;
base02 = colors.base1;
base03 = colors.base0;
base04 = colors.base00;
base05 = colors.base01;
base06 = colors.base02;
base07 = colors.base03;
};
dark = common // {
base00 = colors.base03;
base01 = colors.base02;
base02 = colors.base01;
base03 = colors.base00;
base04 = colors.base0;
base05 = colors.base1;
base06 = colors.base2;
base07 = colors.base3;
};
toRgb = hex: builtins.concatStringsSep "," (
map
(
f: toString (builtins.fromTOML "i = 0x${f hex}").i
)
(
map (pos: builtins.substring pos 2) [ 1 3 5 ]
)
);
makeScheme = colors: {
hex = colors;
rgb = builtins.mapAttrs (_: hex: (toRgb hex)) colors;
};
in
{
inherit colors;
light = makeScheme light;
dark = makeScheme dark;
} }

View file

@ -363,39 +363,38 @@ in
}; };
}; };
xdg.configFile = { xdg.configFile =
"sway/light-theme".text = with solarized; '' let
client.focused ${base01.hex} ${blue.hex} ${base3.hex} ${blue.hex} ${blue.hex} makeTheme = scheme: ''
client.focused_inactive ${base2.hex} ${base2.hex} ${base01.hex} ${base0.hex} ${base2.hex} client.focused ${scheme.base05} ${scheme.base0D} ${scheme.base00} ${scheme.base0D} ${scheme.base0D}
client.unfocused ${base2.hex} ${base3.hex} ${base01.hex} ${base2.hex} ${base2.hex} client.focused_inactive ${scheme.base01} ${scheme.base01} ${scheme.base05} ${scheme.base03} ${scheme.base01}
client.urgent ${red.hex} ${red.hex} ${base3.hex} ${red.hex} ${red.hex} client.unfocused ${scheme.base01} ${scheme.base00} ${scheme.base05} ${scheme.base01} ${scheme.base01}
''; client.urgent ${scheme.base08} ${scheme.base08} ${scheme.base00} ${scheme.base08} ${scheme.base08}
"sway/dark-theme".text = with solarized; ''
client.focused ${base1.hex} ${blue.hex} ${base03.hex} ${blue.hex} ${blue.hex}
client.focused_inactive ${base02.hex} ${base02.hex} ${base1.hex} ${base03.hex} ${base02.hex}
client.unfocused ${base02.hex} ${base03.hex} ${base1.hex} ${base02.hex} ${base02.hex}
client.urgent ${red.hex} ${red.hex} ${base03.hex} ${red.hex} ${red.hex}
''; '';
in
{
"sway/light-theme".text = makeTheme solarized.light.hex;
"sway/dark-theme".text = makeTheme solarized.dark.hex;
"swaynag/config".text = "swaynag/config".text =
let let
# adding it to the header doesnt work since the defaults overwrite it # adding it to the header doesnt work since the defaults overwrite it
commonConfig = /* ini */ '' commonConfig = /* ini */ ''
background=${lib.substring 1 6 solarized.base3.hex} background=${lib.substring 1 6 solarized.colors.base3}
border-bottom=${lib.substring 1 6 solarized.base2.hex} border-bottom=${lib.substring 1 6 solarized.colors.base2}
border=${lib.substring 1 6 solarized.base2.hex} border=${lib.substring 1 6 solarized.colors.base2}
button-background=${lib.substring 1 6 solarized.base3.hex} button-background=${lib.substring 1 6 solarized.colors.base3}
button-text=${lib.substring 1 6 solarized.base00.hex} button-text=${lib.substring 1 6 solarized.colors.base00}
''; '';
in in
/* ini */ '' /* ini */ ''
font=Monospace 12 font=Monospace 12
[warning] [warning]
text=${lib.substring 1 6 solarized.yellow.hex} text=${lib.substring 1 6 solarized.colors.yellow}
${commonConfig} ${commonConfig}
[error] [error]
text=${lib.substring 1 6 solarized.red.hex} text=${lib.substring 1 6 solarized.colors.red}
${commonConfig} ${commonConfig}
''; '';
}; };

View file

@ -18,7 +18,11 @@ let
thinsp = " "; thinsp = " ";
solarized = import ../solarized.nix; solarized = import ../solarized.nix;
solarizedColors = as: lib.strings.concatLines (lib.attrsets.mapAttrsToList (name: value: let color = solarized."${value}".hex; in "@define-color ${name} ${color};") as); solarizedColors = lib.attrsets.mapAttrsToList (name: color: "@define-color ${name} ${color};");
themeCss = {
light = lib.strings.concatLines (solarizedColors solarized.light.hex);
dark = lib.strings.concatLines (solarizedColors solarized.dark.hex);
};
in in
{ {
# home-managers waybar module performs additional checks that are overly strict # home-managers waybar module performs additional checks that are overly strict
@ -253,42 +257,8 @@ in
}; };
xdg.configFile = { xdg.configFile = {
"waybar/theme-light.css".text = solarizedColors { "waybar/theme-light.css".text = themeCss.light;
base00 = "base3"; "waybar/theme-dark.css".text = themeCss.dark;
base01 = "base2";
base02 = "base1";
base03 = "base0";
base04 = "base00";
base05 = "base01";
base06 = "base02";
base07 = "base03";
base08 = "red";
base09 = "orange";
base0A = "yellow";
base0B = "green";
base0C = "cyan";
base0D = "blue";
base0E = "violet";
base0F = "magenta";
};
"waybar/theme-dark.css".text = solarizedColors {
base00 = "base03";
base01 = "base02";
base02 = "base01";
base03 = "base00";
base04 = "base0";
base05 = "base1";
base06 = "base2";
base07 = "base3";
base08 = "red";
base09 = "orange";
base0A = "yellow";
base0B = "green";
base0C = "cyan";
base0D = "blue";
base0E = "violet";
base0F = "magenta";
};
"waybar/style.css".text = '' "waybar/style.css".text = ''
@import "theme.css"; @import "theme.css";

View file

@ -1,46 +1,47 @@
{ lib, ... }: { lib, ... }:
let let
solarized = import ../solarized.nix; inherit (import ../solarized.nix) colors;
in in
{ {
xdg.configFile = { xdg.configFile =
"wofi/color-light".text = lib.strings.concatLines (map (c: solarized."${c}".hex) [ let
"base3" commonColors = with colors; [
"base2" red
"base1" orange
"base0" yellow
"base00" green
"base01" cyan
"base02" blue
"base03" violet
"red" magenta
"orange" ];
"yellow" in
"green" {
"cyan" "wofi/color-light".text = with colors; lib.strings.concatLines (
"blue" [
"violet" base3
"magenta" base2
]); base1
"wofi/color-dark".text = lib.strings.concatLines (map (c: solarized."${c}".hex) [ base0
"base03" base00
"base02" base01
"base01" base02
"base00" base03
"base0" ] ++ commonColors
"base1" );
"base2" "wofi/color-dark".text = with colors; lib.strings.concatLines (
"base3" with colors; [
"red" base03
"orange" base02
"yellow" base01
"green" base00
"cyan" base0
"blue" base1
"violet" base2
"magenta" base3
]); ] ++ commonColors
);
"wofi/style.css".text = '' "wofi/style.css".text = ''
window { window {
margin: 0px; margin: 0px;