{ homeManager, inputs, moduleNameSpace, ... }: { config, lib, pkgs, ... }: let cfg = config.${moduleNameSpace}.matugen; link_zen = pkgs.writeShellScript "link_zen" '' export PROFILE_DIR=$(find ~/.config/zen/ -maxdepth 1 -type d -name "*.Default Profile" | head -n 1) mkdir -p "$PROFILE_DIR/chrome" ln -sf ~/.cache/wallust/userChrome.css "$PROFILE_DIR/chrome/userChrome.css" ln -sf ~/.config/userContent.css "$PROFILE_DIR/chrome/userContent.css" ''; update_gtkcolors = pkgs.writeShellScript "update_gtkcolors" '' dconf write /org/gnome/desktop/interface/color-scheme "'prefer-light'" sleep 0.1 dconf write /org/gnome/desktop/interface/color-scheme "'prefer-dark'" systemctl --user restart xdg-desktop-portal-gtk ''; in { imports = lib.optionals homeManager [ ./templates ]; options.${moduleNameSpace}.matugen = { enable = lib.mkEnableOption "Enable Dynamic colors"; }; config = lib.mkIf cfg.enable ( lib.optionalAttrs homeManager { programs.wallust = { enable = true; settings = { backend = "fastresize"; color_space = "salience"; check_contrast = true; templates = { foot = lib.mkIf config.beeMods.terminal.foot { template = "foot-colors.ini"; target = "~/.config/foot/colors.ini"; }; alacritty = lib.mkIf config.beeMods.terminal.alacritty { template = "alacritty-colors.toml"; target = "~/.config/alacritty/colors.toml"; }; ghostty = lib.mkIf config.beeMods.terminal.ghostty { template = "ghostty-colors.conf"; target = "~/.config/ghostty/colors.conf"; }; zen = { template = "userChrome.css"; target = "~/.cache/wallust/userChrome.css"; }; xresources = lib.mkIf config.beeMods.dwm.enable { template = "colors-xresources"; target = "~/.config/x11/matugen.Xresources"; }; sequences = lib.mkIf (config.beeMods.terminal.default == "foot") { template = "sequences"; target = "~/.config/sequences"; }; }; }; }; home.packages = with pkgs; [ matugen ]; xdg.configFile = { "matugen/config.toml" = { text = # toml '' [config] ${lib.optionalString config.beeMods.terminal.alacritty '' [templates.alacritty] input_path = '~/.config/matugen/templates/alacritty-colors.toml' output_path = '~/.config/wallust/templates/alacritty-colors.toml' ''} ${lib.optionalString config.beeMods.terminal.foot '' [templates.foot] input_path = '~/.config/matugen/templates/foot-colors.ini' output_path = '~/.config/wallust/templates/foot-colors.ini' ''} ${lib.optionalString config.beeMods.terminal.ghostty '' [templates.ghostty] input_path = '~/.config/matugen/templates/ghostty.conf' output_path = '~/.config/wallust/templates/ghostty-colors.conf' ''} ${lib.optionalString config.programs.zathura.enable '' [templates.zathura] input_path = '~/.config/matugen/templates/zathura.toml' output_path = '~/.config/zathura/matugen' ''} ${lib.optionalString config.beeMods.mango.enable '' [templates.swaylock] input_path = '~/.config/matugen/templates/swaylock-colors' output_path = '~/.config/swaylock/swaylock-colors' ''} ${lib.optionalString config.beeMods.mango.enable '' [templates.mango] input_path = '~/.config/matugen/templates/mango.conf' output_path = '~/.config/mango/mango-colors.conf' post_hook = 'mmsg -d reload_config' ''} ${lib.optionalString config.programs.btop.enable '' [templates.btop] input_path = '~/.config/matugen/templates/btop.theme' output_path = '~/.config/btop/themes/matugen.theme' ''} ${lib.optionalString config.programs.yazi.enable '' [templates.yazi] input_path = '~/.config/matugen/templates/yazi.toml' output_path = '~/.config/yazi/theme.toml' ''} ${lib.optionalString config.beeMods.dwm.enable '' [templates.Xresources] input_path = "~/.config/matugen/templates/colors-xresources" output_path = "~/.config/wallust/templates/colors-xresources" ''} ${lib.optionalString config.programs.vesktop.enable '' [templates.vesktop] input_path = "~/.config/matugen/templates/vesktop.css" output_path = "~/.config/vesktop/themes/system24.css" ''} ${lib.optionalString config.beeMods.mango.waybar '' [templates.waybar] input_path = "~/.config/matugen/templates/waybar.css" output_path = "~/.config/waybar/colors.css" # post_hook = "pkill -SIGUSR2 waybar" ''} ${lib.optionalString config.services.dunst.enable '' [templates.dunst] input_path = '~/.config/matugen/templates/dunstrc' output_path = '~/.config/dunst/dunstrc.d/colors.conf' post_hook = "dunstctl reload" ''} ${lib.optionalString config.programs.rofi.enable '' [templates.rofi] input_path = '~/.config/matugen/templates/rofi-colors.rasi' output_path = '~/.config/rofi/shared/colors.rasi' ''} ${lib.optionalString config.gtk.enable '' [templates.gtk3] input_path = '~/.config/matugen/templates/colors.css' output_path = '~/.config/gtk-3.0/colors.css' [templates.gtk4] input_path = '~/.config/matugen/templates/colors.css' output_path = '~/.config/gtk-4.0/colors.css' # post_hook = "${update_gtkcolors}" ''} ${lib.optionalString config.beeMods.beeVim.enable '' [templates.neovim] input_path = "~/.config/matugen/templates/neovim.json" output_path = "~/.config/matugen/neovim_matugen.json" ''} ${lib.optionalString (config.beeMods.terminal.default == "foot") '' [templates.sequences] input_path = '~/.config/matugen/templates/sequences' output_path = '~/.config/wallust/templates/sequences' ''} ${lib.optionalString config.beeMods.bspwm.enable '' [templates.bspwm] input_path = "~/.config/matugen/templates/bspwm-colors" output_path = "~/.config/bspwm/colors" post_hook = "bspc wm -r" ''} [templates.polybar] input_path = "~/.config/matugen/templates/polybar-colors.ini" output_path = "~/.config/polybar/colors.ini" post_hook = "pkill polybar; polybar &" [templates.zed] input_path = '~/.config/matugen/templates/zed.json' output_path = '~/.config/zed/themes/matugen.json' [templates.zen] input_path = '~/.config/matugen/templates/zen.css' output_path = '~/.config/wallust/templates/userChrome.css' post_hook = "${link_zen}" [templates.zen-userContent] input_path = '~/.config/matugen/templates/zen-usercontent.css' output_path = '~/.config/userContent.css' post_hook = "${link_zen}" ''; }; }; } ); }