{ config, pkgs, ... }:
{
  # additional deps for cava support
  home.packages = with pkgs; [
    iniparser
    fftw
  ];

  systemd.user.services.waybar = {
    Unit.StartLimitBurst = 30;
    # this fixes fonts for some reason
    Service.Environment = "PATH=${config.home.profileDirectory}/bin";
  };
  programs.waybar = {
    enable = true;
    systemd.enable = true;
    settings = {
      primary = {
        height = 30;
        position = "top";
        margin-top = 10;
        margin-left = 20;
        margin-right = 20;
        modules-left = [
          "hyprland/workspaces"
          "hyprland/language"
        ];

        modules-center = [
          "cpu"
          "clock"
          "memory"
        ];

        modules-right = [
          "mpris"
          "network"
          "pulseaudio"
          "battery"
          "tray"
        ];

        cpu = {
          format = "CPU {usage}%";
        };

        memory = {
          format = "MEM {}%";
        };

        tray = {
          spacing = 10;
        };

        pulseaudio = {
          format = "AUD {volume}%";
        };

        network = {
          format = "NET {ipaddr}";
          format-disconnected = "NET X";
        };

        mpris = {
          format = "{dynamic}";
          interval = 1;
        };

        "hyprland/language" = {
          format = "KBD {}";
          format-en = "EN";
          format-de = "DE";
        };
      };
    };

    style =
      let
        inherit (config.lib.stylix.colors) withHashtag;
      in
      ''
        * {
          font-family: ${config.fontProfiles.bitmap.family}, ${config.fontProfiles.monospace.family};
          font-size: 11pt;
          padding: 0;
        }

        window#waybar {
          padding: 0;
          border-radius: 0.5em;
        }

        #workspaces {
          transition: background-color .5s, color .5s;
        }

        #workspaces button {
          padding: 0 6px;
        }

        #workspaces button.active,
        #workspaces button.focused {
          background-color: ${withHashtag.base05};
          color: ${withHashtag.base00};
        }

        #cpu,
        #memory {
          color: ${withHashtag.base04};
        }

        #mpris {
          font-size: 10pt;
          margin-right: 6px;
        }

        #tray {
          padding: 0 5px;
          background-color: ${withHashtag.base02};
        }

        #pulseaudio {
          color: ${withHashtag.base0D};
        }

        #network {
          color: ${withHashtag.base0C};
        }

        #language {
          color: ${withHashtag.base02};
          margin-left: 10px;
        }
      '';
  };
}