{
  options,
  config,
  pkgs,
  lib,
  inputs,
  ...
}:
with lib;
with lib.frajul;
let
  cfg = config.modules.desktop.addons.waybar;
  inherit (inputs.nix-colors.colorschemes.${builtins.toString config.modules.desktop.colorscheme})
    palette
    ;
in
{
  options.modules.desktop.addons.waybar = with types; {
    enable = mkBoolOpt false "Enable or disable waybar";
  };

  config = mkIf cfg.enable {
    programs.waybar = {
      enable = true;
      systemd.enable = true;
      settings.mainBar = builtins.fromJSON (builtins.readFile ./config.json);
    };

    xdg.configFile."waybar/style.css".source = ./style.css;
    xdg.configFile."waybar/theme.css".text = ''
      /*
      bg - background
      fg - foreground
      */

      /* Main Colors */
      @define-color background        #${palette.base00};
      @define-color foreground        #${palette.base05};

      /* Workspace Button Colors */
      @define-color hover-bg          #${palette.base01};
      @define-color hover-fg          #${palette.base05};
      @define-color active-bg         #${palette.base02};
      @define-color active-fg         #${palette.base0A};
      @define-color urgent-bg         #${palette.base08};
      @define-color urgent-fg         #${palette.base00};
    '';
  };
}
