# ./modules/users/psljr/waybar.nix
# Configure the waybar status bar for user psljr

{ config, pkgs, ... }:

{
  home-manager.users.psljr = { pkgs, ... }: {
    programs.waybar = {
      enable = true;

      settings = {
        mainBar = {
          layer = "top";
          position = "top";
          spacing = 4;

          # Define waybar modules
          modules-left = [
            "hyprland/window"
          ];
          # modules-center = [];
          modules-right = [
            "idle_inhibitor"
            "network"
            "bluetooth"
            "cpu"
            "memory"
            "battery"
            "clock"
          ];

          # Module configuration
          "idle_inhibitor" = {
            format = "{icon}";
            format-icons = {
              activated = "";
              deactivated = "";
            };
          };

          "network" = { 
            "format-wifi" = "   {essid} ({signalStrength}%)";
            "format-ethernet" = "{ipaddr}/{cidr} ";
            "tooltip-format" = "{ifname} via {gwaddr} ";
            "format-linked" = "{ifname} (No IP) ";
            "format-disconnected" = "Disconnected ⚠";
            "on-click" = "rofi-network-manager";
          };

          "bluetooth" = {
            "format" = " {status}";
            "format-connected" = " {status}";
            "tooltip-format" = "{controller_alias}\t{controller_address}\n\n{num_connections} connected";
            "on-click" = "rofi-bluetooth";
          };

          "cpu" = {
            "format" = "  {usage}%";
            "tooltip" = true;
          };

          "memory" = {
            "format" = " {}%";
            "tooltip" = true;
          };

          "battery" = {
            "states" = {
              "warning" = 30;
              "critical" = 15;
            };

            "format" = "{icon}  {capacity}%";
            "format-full" = "{icon}  {capacity}%";
            "format-charging" = "  {capacity}%";
            "format-plugged" = "  {capacity}%";
            "format-alt" = "{time}  {icon}";
            "format-icons" = ["" "" "" "" ""];
          };

          "clock" = {
            "format" = "{:%H:%M | %e %B} ";
            "tooltip-format" = "<big>{:%Y %B}</big>\n<tt><small>{calendar}</small></tt>";
          };
        };
      };

      style = ''
        * {
          /* `otf-font-awesome` and SpaceMono Nerd Font are required to be installed for icons */
          font-family: JetbrainsMono, FontAwesome, Roboto, Helvetica, Arial, sans-serif;
          font-size: 10px;
          transition: background-color .3s ease-out;
        }

        window#waybar {
            background: rgba(38, 38, 38, 0.75);
            color: #F7F7F7;
            font-family:
                SpaceMono Nerd Font,
                feather;
            transition: background-color .5s;
        }
        
        .modules-left,
        .modules-right
        {
            background: rgba(0, 0, 8, .7);
            margin: 5px 10px;
            padding: 5 5px;
            border-radius: 10px;
        }
        .modules-left {
            padding: 0 10px;
        }
        
        #clock,
        #battery,
        #cpu,
        #memory,
        #disk,
        #temperature,
        #backlight,
        #network,
        #pulseaudio,
        #wireplumber,
        #custom-media,
        #tray,
        #mode,
        #idle_inhibitor,
        #scratchpad,
        #power-profiles-daemon,
        #language,
        #mpd {
            padding: 0 10px;
            border-radius: 10px;
        }
        
        #clock:hover,
        #battery:hover,
        #cpu:hover,
        #memory:hover,
        #disk:hover,
        #temperature:hover,
        #backlight:hover,
        #network:hover,
        #pulseaudio:hover,
        #wireplumber:hover,
        #custom-media:hover,
        #tray:hover,
        #mode:hover,
        #idle_inhibitor:hover,
        #scratchpad:hover,
        #power-profiles-daemon:hover,
        #language:hover,
        #mpd:hover {
            background: rgba(38, 38, 38, 0.9);
        }
      '';
    };
  };
}
