# Builds matugen config.toml text for DMS dynamic theming.
{
  lib,
  home,
  hyprlandEnabled,
  ohMyPoshEnabled,
  discordEnabled,
  obsidianSnippetDirs,
}:
let
  templateBlock = name: input: output: ''

    [templates.${name}]
    input_path = '${input}'
    output_path = '${output}'
  '';
in
''
[config]
''
+ lib.optionalString hyprlandEnabled (
  templateBlock "hyprland"
    "${home}/.config/matugen/templates/hyprland-colors.conf"
    "${home}/.config/hypr/colors.conf"
)
+ lib.optionalString ohMyPoshEnabled (
  templateBlock "ohmyposh"
    "${home}/.config/matugen/templates/ohmyposh-theme.omp.json"
    "${home}/.config/oh-my-posh/theme.omp.json"
)
+ lib.optionalString discordEnabled (
  templateBlock "dank-discord"
    "${home}/.config/matugen/templates/dank-discord.css"
    "${home}/.config/vesktop/themes/dank-discord.css"
)
+ lib.optionalString (obsidianSnippetDirs != [ ]) (
  lib.concatStringsSep "\n" (
    lib.lists.imap0 (i: snippetDir:
      templateBlock "Obsidian${toString i}"
        "${home}/.config/matugen/templates/obsidian-minimal-matugen-colors.css"
        "${snippetDir}/matugen.css"
    ) obsidianSnippetDirs
  )
)
