diff --git a/home-manager/modules/dynamic-colors.nix b/home-manager/modules/dynamic-colors.nix index 0da283f..e5a4587 100644 --- a/home-manager/modules/dynamic-colors.nix +++ b/home-manager/modules/dynamic-colors.nix @@ -1,6 +1,11 @@ { nixosConfig, lib, config, pkgs, ... }: let + loadSwayTheme = pkgs.writeShellScript "load-sway-theme" '' + while IFS= read -r line; do + ${pkgs.sway}/bin/swaymsg "$line" + done < "$1" + ''; applicationConfig = [ { dir = "~/.config/alacritty"; @@ -14,12 +19,20 @@ let dark = "color-dark"; target = "color"; } + { + dir = "~/.config/sway"; + light = "light-theme"; + dark = "dark-theme"; + target = "theme"; + exec = [ loadSwayTheme "theme" ]; + } ]; dynamic-colors = pkgs.writers.writePython3Bin "dynamic-colors" { } '' + import json import os import pathlib + import subprocess import sys - import json def main(): @@ -49,6 +62,9 @@ let os.symlink(entry['light'], target) + if 'exec' in entry: + subprocess.run(entry['exec'], cwd=directory) + if __name__ == '__main__': main() diff --git a/home-manager/modules/sway/default.nix b/home-manager/modules/sway/default.nix index 0ce1fe3..418e168 100644 --- a/home-manager/modules/sway/default.nix +++ b/home-manager/modules/sway/default.nix @@ -73,6 +73,19 @@ in end ''; + 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} + ''; + xdg.configFile."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} + ''; + wayland.windowManager.sway = { enable = true; @@ -269,37 +282,6 @@ in border = 1; }; - colors = { - focused = rec { - border = solarized.base1.hex; - background = solarized.base2.hex; - text = solarized.base1.hex; - indicator = solarized.cyan.hex; - childBorder = background; - }; - focusedInactive = rec { - border = solarized.base0.hex; - background = solarized.base03.hex; - text = solarized.base0.hex; - indicator = solarized.cyan.hex; - childBorder = background; - }; - unfocused = rec { - border = solarized.base0.hex; - background = solarized.base03.hex; - text = solarized.base0.hex; - indicator = solarized.cyan.hex; - childBorder = background; - }; - urgent = rec { - border = solarized.base02.hex; - background = solarized.red.hex; - text = solarized.base02.hex; - indicator = solarized.cyan.hex; - childBorder = background; - }; - }; - fonts = { names = [ "monospace" ]; style = "Regular"; @@ -308,6 +290,7 @@ in }; extraConfig = '' + include ~/.config/sway/theme # Cursor seat seat0 xcursor_theme Adwaita '' + (