diff --git a/users/jalr/modules/solarized.nix b/users/jalr/modules/solarized.nix index 5390a31..baa2547 100644 --- a/users/jalr/modules/solarized.nix +++ b/users/jalr/modules/solarized.nix @@ -1,23 +1,68 @@ -builtins.mapAttrs - (_: hex: { - inherit hex; - rgb = builtins.concatStringsSep "," (map (f: toString (builtins.fromTOML "i = 0x${f hex}").i) (map (pos: builtins.substring pos 2) [ 1 3 5 ])); - }) +let + colors = { + base00 = "#657b83"; + base01 = "#586e75"; + base02 = "#073642"; + base03 = "#002b36"; + base0 = "#839496"; + base1 = "#93a1a1"; + base2 = "#eee8d5"; + base3 = "#fdf6e3"; + blue = "#268bd2"; + cyan = "#2aa198"; + green = "#859900"; + magenta = "#d33682"; + orange = "#cb4b16"; + red = "#dc322f"; + violet = "#6c71c4"; + 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 { - base00 = "#657b83"; - base01 = "#586e75"; - base02 = "#073642"; - base03 = "#002b36"; - base0 = "#839496"; - base1 = "#93a1a1"; - base2 = "#eee8d5"; - base3 = "#fdf6e3"; - blue = "#268bd2"; - cyan = "#2aa198"; - green = "#859900"; - magenta = "#d33682"; - orange = "#cb4b16"; - red = "#dc322f"; - violet = "#6c71c4"; - yellow = "#b58900"; + inherit colors; + light = makeScheme light; + dark = makeScheme dark; } diff --git a/users/jalr/modules/sway/default.nix b/users/jalr/modules/sway/default.nix index 2202b71..2d7bb71 100644 --- a/users/jalr/modules/sway/default.nix +++ b/users/jalr/modules/sway/default.nix @@ -363,40 +363,39 @@ in }; }; - xdg.configFile = { - "sway/light-theme".text = with solarized; '' - client.focused ${base01.hex} ${blue.hex} ${base3.hex} ${blue.hex} ${blue.hex} - client.focused_inactive ${base2.hex} ${base2.hex} ${base01.hex} ${base0.hex} ${base2.hex} - client.unfocused ${base2.hex} ${base3.hex} ${base01.hex} ${base2.hex} ${base2.hex} - client.urgent ${red.hex} ${red.hex} ${base3.hex} ${red.hex} ${red.hex} - ''; - "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} - ''; - "swaynag/config".text = - let - # adding it to the header doesn’t work since the defaults overwrite it - commonConfig = /* ini */ '' - background=${lib.substring 1 6 solarized.base3.hex} - border-bottom=${lib.substring 1 6 solarized.base2.hex} - border=${lib.substring 1 6 solarized.base2.hex} - button-background=${lib.substring 1 6 solarized.base3.hex} - button-text=${lib.substring 1 6 solarized.base00.hex} - ''; - in - /* ini */ '' - font=Monospace 12 - - [warning] - text=${lib.substring 1 6 solarized.yellow.hex} - ${commonConfig} - - [error] - text=${lib.substring 1 6 solarized.red.hex} - ${commonConfig} + xdg.configFile = + let + makeTheme = scheme: '' + client.focused ${scheme.base05} ${scheme.base0D} ${scheme.base00} ${scheme.base0D} ${scheme.base0D} + client.focused_inactive ${scheme.base01} ${scheme.base01} ${scheme.base05} ${scheme.base03} ${scheme.base01} + client.unfocused ${scheme.base01} ${scheme.base00} ${scheme.base05} ${scheme.base01} ${scheme.base01} + client.urgent ${scheme.base08} ${scheme.base08} ${scheme.base00} ${scheme.base08} ${scheme.base08} ''; - }; + in + { + "sway/light-theme".text = makeTheme solarized.light.hex; + "sway/dark-theme".text = makeTheme solarized.dark.hex; + "swaynag/config".text = + let + # adding it to the header doesn’t work since the defaults overwrite it + commonConfig = /* ini */ '' + background=${lib.substring 1 6 solarized.colors.base3} + border-bottom=${lib.substring 1 6 solarized.colors.base2} + border=${lib.substring 1 6 solarized.colors.base2} + button-background=${lib.substring 1 6 solarized.colors.base3} + button-text=${lib.substring 1 6 solarized.colors.base00} + ''; + in + /* ini */ '' + font=Monospace 12 + + [warning] + text=${lib.substring 1 6 solarized.colors.yellow} + ${commonConfig} + + [error] + text=${lib.substring 1 6 solarized.colors.red} + ${commonConfig} + ''; + }; }) diff --git a/users/jalr/modules/sway/waybar.nix b/users/jalr/modules/sway/waybar.nix index 628e3e8..b30d1ae 100644 --- a/users/jalr/modules/sway/waybar.nix +++ b/users/jalr/modules/sway/waybar.nix @@ -18,7 +18,11 @@ let thinsp = " "; 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 { # home-manager’s waybar module performs additional checks that are overly strict @@ -253,42 +257,8 @@ in }; xdg.configFile = { - "waybar/theme-light.css".text = solarizedColors { - base00 = "base3"; - 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/theme-light.css".text = themeCss.light; + "waybar/theme-dark.css".text = themeCss.dark; "waybar/style.css".text = '' @import "theme.css"; diff --git a/users/jalr/modules/sway/wofi.nix b/users/jalr/modules/sway/wofi.nix index ca8eb9a..44d2914 100644 --- a/users/jalr/modules/sway/wofi.nix +++ b/users/jalr/modules/sway/wofi.nix @@ -1,91 +1,92 @@ { lib, ... }: let - solarized = import ../solarized.nix; + inherit (import ../solarized.nix) colors; in { - xdg.configFile = { - "wofi/color-light".text = lib.strings.concatLines (map (c: solarized."${c}".hex) [ - "base3" - "base2" - "base1" - "base0" - "base00" - "base01" - "base02" - "base03" - "red" - "orange" - "yellow" - "green" - "cyan" - "blue" - "violet" - "magenta" - ]); - "wofi/color-dark".text = lib.strings.concatLines (map (c: solarized."${c}".hex) [ - "base03" - "base02" - "base01" - "base00" - "base0" - "base1" - "base2" - "base3" - "red" - "orange" - "yellow" - "green" - "cyan" - "blue" - "violet" - "magenta" - ]); - "wofi/style.css".text = '' - window { - margin: 0px; - border: 3px solid --wofi-color1; - border-radius: 8px; - background-color: rgba(--wofi-rgb-color0,0.8); - } + xdg.configFile = + let + commonColors = with colors; [ + red + orange + yellow + green + cyan + blue + violet + magenta + ]; + in + { + "wofi/color-light".text = with colors; lib.strings.concatLines ( + [ + base3 + base2 + base1 + base0 + base00 + base01 + base02 + base03 + ] ++ commonColors + ); + "wofi/color-dark".text = with colors; lib.strings.concatLines ( + with colors; [ + base03 + base02 + base01 + base00 + base0 + base1 + base2 + base3 + ] ++ commonColors + ); + "wofi/style.css".text = '' + window { + margin: 0px; + border: 3px solid --wofi-color1; + border-radius: 8px; + background-color: rgba(--wofi-rgb-color0,0.8); + } - #input { - margin: 5px; - border: none; - color: --wofi-color4; - background-color: rgba(--wofi-rgb-color1,0.8); - } + #input { + margin: 5px; + border: none; + color: --wofi-color4; + background-color: rgba(--wofi-rgb-color1,0.8); + } - #inner-box { - margin: 5px; - border: none; - background: none; - } + #inner-box { + margin: 5px; + border: none; + background: none; + } - #outer-box { - margin: 5px; - border: none; - background: none; - } + #outer-box { + margin: 5px; + border: none; + background: none; + } - #scroll { - margin: 0px; - border: none; - } + #scroll { + margin: 0px; + border: none; + } - #text { - margin: 5px; - border: none; - color: --wofi-color4; - } + #text { + margin: 5px; + border: none; + color: --wofi-color4; + } - #entry:selected { - background-color: rgba(--wofi-rgb-color1,0.8); - } + #entry:selected { + background-color: rgba(--wofi-rgb-color1,0.8); + } - #entry:selected #text{ - color: --wofi-color11; - } - ''; - }; + #entry:selected #text{ + color: --wofi-color11; + } + ''; + }; }