{
  pkgs,
  lib,
  config,
  ...
}: let
  program = "waybar";
  cfg = config.dots.${program};
  #sec = sops.secrets;
in {
  options.dots.${program} = {
    enable = lib.mkEnableOption "enables ${program}";
  };

  config = lib.mkIf cfg.enable {
    # just using the normal lfrc
    programs.${program} = {
      enable = true;
      systemd = {
        enable = false;
        target = "graphical-session.target";
      };

      settings = {
        mainBar = {
          layer = "top";
          position = "top";
          height = 25;
          margin-top = 0;

          modules-left = ["hyprland/workspaces"];
          modules-center = ["hyprland/window"];
          modules-right = [
            "tray"
            "temperature"
            "backlight"
            "wireplumber"
            "battery"
            "bluetooth"
            "network"
            "idle_inhibitor"
            "clock"
          ];

          "hyprland/workspaces" = {
            format = "{icon}";
            "on-scroll-up" = "hyprctl dispatch workspace e+1";
            "on-scroll-down" = "hyprctl dispatch workspace e-1";
          };

          "hyprland/window" = {
            "max-length" = 200;
            "separate-outputs" = false;
          };

          tray = {
            "icon-size" = 17;
            spacing = 10;
          };

          clock = {
            format = "{:%Y/%m/%d %a %H:%M}";
            interval = 30;
            "on-click" = "thunderbird -calendar";
            "on-scroll" = 1;

            calendar = {
              mode = "month";
              "mode-mon-col" = 3;
              "weeks-pos" = "";
              "on-scroll" = 1;
              "on-click-right" = "mode";
              format = {
                months = "<span color='#ffead3'><b>{}</b></span>";
                days = "<span color='#ecc6d9'><b>{}</b></span>";
                weeks = "<span color='#99ffdd'><b>W{}</b></span>";
                weekdays = "<span color='#ffcc66'><b>{}</b></span>";
                today = "<span color='#ff6699'><b><u>{}</u></b></span>";
              };
            };

            actions = {
              "on-click-right" = "mode";
              "on-scroll-up" = "shift_up";
              "on-scroll-down" = "shift_down";
            };

            "tooltip-format" = "<tt><small>{calendar}</small></tt>";
          };

          backlight = {
            device = "intel_backlight";
            format = "{icon} {percent}%";
            "format-icons" = ["☼" "☼" "☀" "☀"];
            interval = 60;
          };

          temperature = {
            "hwmon-path" = ["/sys/class/hwmon/hwmon3/temp1_input"];
            "critical-threshold" = 70;
            format = "";
            "format-critical" = " {temperatureC}°C";
          };

          battery = {
            bat = "BAT0";
            states = {
              full = 99;
              good = 80;
              normal = 50;
              warning = 30;
              critical = 10;
            };
            format = "{icon}  {capacity}%";
            "format-charging" = "  {capacity}%";
            "format-icons" = ["" "" "" "" ""];
            interval = 30;
          };

          network = {
            "format-wifi" = "";
            "format-ethernet" = "󰈀";
            "format-disconnected" = "󰖪";
            "tooltip-format-wifi" = "{ifname} / {essid}\n\n      {ipaddr}\n\n  󰘊 {signalStrength}%   /   󰥛 {frequency}\n\n 󰕒 {bandwidthUpBits} / 󰇚 {bandwidthDownBits}";
            "tooltip-format-ethernet" = "{ifname} / {gwaddr}\n\n       {ipaddr}\n\n 󰕒 {bandwidthUpBits} / 󰇚 {bandwidthDownBits}";
            "tooltip-format-disconnected" = "Disconnected";
            interval = 5;
            "on-click" = "kitty nmtui";
          };

          wireplumber = {
            format = "  {volume}%";
            "format-muted" = "󰝟  Mute";
            "max-volume" = 150;
            "on-scroll-up" = "wpctl set-volume -l 1.5 @DEFAULT_AUDIO_SINK@ 1%+";
            "on-scroll-down" = "wpctl set-volume @DEFAULT_AUDIO_SINK@ 1%-";
            "on-click-right" = "wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle";
            "on-click" = "kitty pulsemixer";
          };

          bluetooth = {
            "format-on" = "󰂯";
            "format-off" = "󰂲";
            "format-connected" = "󰂯 {device_alias}";
            "format-connected-battery" = "󰥉 {device_alias} ({device_battery_percentage}%)";
            "tooltip-format-off" = "Controller Powered Off";
            "tooltip-format" = "{controller_alias}\t{controller_address}\n\n{num_connections} connected";
            "tooltip-format-connected" = "{controller_alias}\t{controller_address}\n\n{num_connections} connected\n\n{device_enumerate}";
            "tooltip-format-enumerate-connected" = "{device_alias}\t{device_address}";
            "tooltip-format-enumerate-connected-battery" = "{device_alias}\t{device_address}\t{device_battery_percentage}%";
            "on-click" = "kitty bluetuith --no-warning";
            "on-click-right" = "if bluetoothctl show|grep -q 'Powered: yes';then bluetoothctl power off;else bluetoothctl power on;fi";
          };

          idle_inhibitor = {
            what = "idle";
            format = "{icon}";
            "format-icons" = {
              activated = "";
              deactivated = "";
            };
          };
        };
      };

      style = lib.mkAfter ''
        * {
            border: none;
            font-family: "UbuntuMono Nerd Font";
            font-size: 17px;
        }

        .modules-left {
            border-radius: 9px;
          background-color: rgba(50, 50, 50, 0.5);
          padding: 0px 0px 0px 0px;
        }

        .modules-right {
            border-radius: 9px;
          background-color: rgba(50, 50, 50, 0.5);
          padding: 0px 5px 0px 0px;
        }

        /* --- window bar --- */

        /* window title bar */
        window#waybar {
            border-radius: 9px;
            background-color: rgba(47, 23, 48, 0.70);
            color: #ffffff;
        }

        /* hide window title when empty*/
        window#waybar.empty #window {
          background-color: transparent;
          color: transparent;
        }

        /* change title bar background color when empty */
        window#waybar.empty {
          background-color: rgba(47, 23, 48, 0.70);
        }

        /* --- left modules --- */

        /* workspace buttons */
        #workspaces button {
            box-shadow: inset 0 -3px transparent;
          padding: 0px 11px 0px 11px;
          min-width: 1px;
          color: #888888;
        }

        #workspaces button:hover {
            box-shadow: inherit;
            text-shadow: inherit;
            background: rgba(50, 50, 50, 0.55);
          color: #888888;
        }

        #workspaces button.active,
        #workspaces button.visible {
          padding: 0px 11px 0px 11px;
          background-color: rgba(50, 50, 50, 0.55);
          color: #e2c7c7;
        }

        /* --- right modules --- */

        #tray {
           margin: 0px 10px 0px 5px;
        }

        #clock {
          margin: 0px 3px 0px 13px;
        }

        #idle_inhibitor,
        #network,
        #bluetooth,
        #battery,
        #wireplumber,
        #backlight,
        #temperature {
          background-color: transparent;
            color: #ffffff;
            padding: 0px 10px 0px 10px;
        }


        #bluetooth {
          background-color: transparent;
            color: #ffffff;
            padding: 0px 4px 0px 10px;
        }

        /* --- indicators --- */

        /* blink red */
        #temperature.critical,
        #battery.critical:not(.charging) {
           background-color: transparent;
           animation-name: blink;
           animation-duration: 0.75s;
           animation-timing-function: steps(12);
           animation-iteration-count: infinite;
           animation-direction: alternate;
        }

        /* turn red */
        #network.disconnected,
        #wireplumber.muted,
        #bluetooth.off {
           color: #ff5555;
        }

        /* --- animations --- */

        @keyframes blink {
            to {
                background-color: transparent;
                color: #ff5555;
            }
        }

      '';
    };

    # install it to userspace
    home.packages = with pkgs; [
      pulsemixer
      brightnessctl
      bluetuith
      bluez
    ];
  };
}
