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

{
  config = lib.mkIf config.haze.apps.waybar.enable {
    programs.waybar = {
      enable = true;
      style = ./style.css;
      settings = {
        mainBar = {
          "layer" = "top";
          "position" = "top";
          "margin" = "0, 0, 0, 0";
          "ipc" = true;

          "modules-left" = ["sway/workspaces" "sway/scratchpad" "sway/mode"];
          "modules-center" = ["mpris"];
          "modules-right" = ["tray" "backlight" "pulseaudio" "battery" "clock"];

          "sway/scratchpad" = {
            "format" = "{icon} {count}";
            "show-empty" = false;
            "format-icons" = ["" "ï‹’"];
            "tooltip" = true;
            "tooltip-format" = "{app}: {title}";
          };

          "idle_inhibitor" = {
            "format" = "{icon}";
            "format-icons" = {
              "activated" = "ï�®";
              "deactivated" = "ï�°";
            };
          };
          "clock" = {
            "tooltip-format" = "<big>{:%Y %B}</big>\n<tt><small>{calendar}</small></tt>";
            "format-alt" = "{:%Y-%m-%d}";
          };
          "backlight" = {
            "format" = "{percent}% {icon}";
            "format-icons" = ["î��" "î�“" "î�‘" "î��" "î��" "î��" "î�Š" "î�ˆ" "î�›"];
          };
          "pulseaudio" = {
            "format" = "{format_source} {volume}% {icon}";
            "format-bluetooth" = "{format_source} {volume}% {icon}ïŠ”";
            "format-bluetooth-muted" = "{format_source} ï‘¦ {icon}ïŠ”";
            "format-muted" = "{format_source} ï‘¦ ";
            "format-source" = "ï„°";
            "format-source-muted" = "ï„±";
            "format-icons" = {
              "headphone" = "ó°‹‹";
              "hands-free" = "ó°¥°";
              "headset" = "ó°‹�";
              "phone" = "ï‚•";
              "portable" = "ï‚•";
              "car" = "ï†¹";
              "default" = ["ï€¦" "ï€§" "ï€¨"];
            };
            "on-click" = "pavucontrol";
          };
          "battery" = {
            "states" = {
              "good" = 95;
              "warning" = 30;
              "critical" = 15;
            };
            "format" = "{capacity}% {icon}";
            "format-charging" = "{capacity}% ó±�‹";
            "format-plugged" = "{capacity}% ï‡¦";
            "format-alt" = "{time} {icon}";
            "format-icons" = ["ï‰„" "ï‰ƒ" "ï‰‚" "ï‰�" "ï‰€"];
          };
          "mpris" = {
            "format" = "{player_icon} {dynamic}";
            "format-paused" = "{status_icon} <i>{dynamic}</i>";
            "player-icons" = {
              "default" = "â–¶";
              "spotify_player" = "ğŸ�µ";
              "strawberry" = "ğŸ�µ";
            };
            "status-icons" = {
              "paused" = "â�¸";
            };
            "ignored-players" = ["firefox"];
            "on-click" = "playerctl pause media";
          };
        };
      };
    };
  };
}
