Implement dynamic-colors for sway

This commit is contained in:
Jakob Lechner 2023-11-17 02:31:24 +00:00
parent af91a9979c
commit 02f4aeb248
No known key found for this signature in database
GPG key ID: 996082EFB5906C10
2 changed files with 31 additions and 32 deletions

View file

@ -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()

View file

@ -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
'' + (