{ config, pkgs, lib, ... }:

let
  activeTheme = config.nomarchy.theme;
  
  # Path to local theme files
  themeDir = ./themes + "/${activeTheme}";
  hasThemeConfig = builtins.pathExists (themeDir + "/config.jsonc");
  hasThemeStyle = builtins.pathExists (themeDir + "/style.css");
  
  # Default fallback files
  defaultConfig = ./config/config.jsonc;
  defaultStyle = ./config/style.css;
  
  # Selected files
  configFile = if hasThemeConfig then (themeDir + "/config.jsonc") else defaultConfig;
  styleFile = if hasThemeStyle then (themeDir + "/style.css") else defaultStyle;
  
in
{
  programs.waybar = {
    enable = lib.mkDefault true;
    systemd.enable = lib.mkDefault true;
    
    settings = lib.mkDefault [ (builtins.fromJSON (builtins.readFile configFile)) ];
    style = lib.mkDefault (builtins.readFile styleFile);
  };

  home.packages = lib.mkDefault (with pkgs; [
    font-awesome
  ]);
}
