// ============================================================
// Waybar Config — Hyprland Cyberqueer Setup
// ============================================================
// Waybar is the taskbar/statusbar displayed at the top of the
// Hyprland Wayland compositor. This JSON5 file (comments and
// trailing commas allowed) defines every module shown on the
// bar: position, update intervals, display formats, click
// actions, and hover tooltips.
//
// Cyberqueer color palette (referenced throughout):
//   #1a1a1a — near-black background
//   #5018dd — deep electric purple (inactive / cool accent)
//   #E40046 — hot neon red/pink (active / warm accent)
//   #d6abab — muted dusty rose (readable text / neutral)
//   #f50505 — bright red (critical / alert states)
// ============================================================
{
  // ── Bar placement ──────────────────────────────────────────
  // "layer": "top" — the bar sits above all other windows so
  // it is never covered by maximized applications.
  // "position": "top" — anchored to the top edge of the screen.
  "layer": "top", "position": "top",

  // ── Module layout ──────────────────────────────────────────
  // Waybar divides the bar into three zones: left, center, right.
  // The order within each list is the left-to-right display order.
  "modules-left": ["clock", "disk", "memory", "cpu", "temperature" ],
  // Center: Hyprland workspace switcher + currently focused window title.
  "modules-center": [  "hyprland/workspaces", "hyprland/window"],
  // Right: network icon, local IP, system tray, audio volume, battery.
  "modules-right": [ "network", "custom/netaddrsimple", "tray", "pulseaudio", "battery" ],

  // Automatically reload style.css when the file changes on disk,
  // so appearance tweaks take effect without restarting waybar.
  "reload_style_on_change":true,

  // ── custom/netaddrsimple ───────────────────────────────────
  // A bare-minimum custom module that shows the machine's local IP.
  // Handy for quickly finding the address to SSH into.
  	"custom/netaddrsimple": {
		// {} is substituted with the stdout of the exec command.
		"format": "IP:{}",
		// No tooltip needed — the IP text in the bar is sufficient.
		"tooltip":false,
		// (Commented out) would limit the displayed text to 15 characters.
		//"max-length": 15,
		// Refresh every 10 seconds — local IP rarely changes.
		"interval": 10,
		// "hostname -i" prints the machine's primary local IP address.
		"exec": "hostname -i",
	},

  // ── hyprland/workspaces ───────────────────────────────────
  // Shows clickable workspace number buttons.
  // Mouse-wheel scrolling switches workspaces sequentially.
  	"hyprland/workspaces": {
  			// Display the workspace name (typically its number) as label text.
  			"format": "{name}",
  			// These icon overrides replace the label when a workspace matches
  			// the "default", "active", or "urgent" state keys.
  			"format-icons": {
  					// Unfocused, non-urgent workspaces get a plain bullet.
  					"default": " ",
  					// The currently focused workspace is marked with "@".
  					"active": "@",
  					// A workspace with an urgent app (needs attention) shows "!".
  					"urgent": "!"
  				},
  			// Scroll wheel up → move to numerically higher workspace.
  			"on-scroll-up": "hyprctl dispatch workspace e+1",
  			// Scroll wheel down → move to numerically lower workspace.
  			"on-scroll-down": "hyprctl dispatch workspace e-1",
  			},
  			// NOTE: this clock block is structurally inside the workspaces
  			// object due to a brace mismatch in the original config.
  			// The top-level "clock" block defined further below takes
  			// precedence and is what waybar actually uses.
  			"clock": {
  				// Locale-aware HH:MM format (24-hour).
  				"format": "{:L%H:%M}",
  				"tooltip": true,
  				// Tooltip shows a large date line and a small monthly calendar.
  				"tooltip-format": "<big>{:%A, %d.%B %Y }</big>\n<tt><small>{calendar}</small></tt>"
  			}
  	},


// ── idle_inhibitor ────────────────────────────────────────
// Prevents the system from going idle / blanking the screen
// while activated. Toggle by clicking the module.
"idle_inhibitor":{
  // Wrap the icon in a larger font-size span so the glyph is readable.
  "format": "<span font='12'>{icon} </span>",
  "format-icons": {
    // Nerd Font "eye open" — currently inhibiting idle / screen-off.
    "activated":"󰈈",
    // Nerd Font "eye closed" — idle allowed normally.
    "deactivated":"󰈉"
  }
},

// ── clock ─────────────────────────────────────────────────
// Real-time HH:MM:SS clock shown in the left section.
// Updates every second so the seconds digit stays live.
"clock": {
      // Show hours, minutes, and seconds with a trailing space.
      "format": "{:%H:%M:%S }",
      // 1-second interval to keep the clock accurate to the second.
      "interval":1,
      // Tooltip: a large date header plus a mini monthly calendar.
      "tooltip-format": "\n<big>{:%d %m %Y}</big>\n<tt><small>{calendar}</small></tt>",
      // Display ISO week numbers on the right side of the calendar grid.
      "calendar-weeks-pos": "right",
      // Highlight today's date cell in the cyberqueer purple (#7645AD).
      "today-format": "<span color='#7645AD'><b><u>{}</u></b></span>",
      // Calendar day numbers in muted grey so they don't compete visually.
      "format-calendar": "<span color='#aeaeae'><b>{}</b></span>",
      // Week-number column label (e.g. "W24") in the same muted grey.
      "format-calendar-weeks": "<span color='#aeaeae'><b>W{:%V}</b></span>",
      // Weekday header row (Mon, Tue…) in muted grey.
      "format-calendar-weekdays": "<span color='#aeaeae'><b>{}</b></span>"
      },

  // ── bluetooth ────────────────────────────────────────────
  // Bluetooth state indicator using Nerd Font glyphs.
  // Clicking opens rofi-bluetooth for pairing/device management.
  "bluetooth": {
  // Bluetooth is on but nothing is connected.
  "format-on": "",
  // Bluetooth is turned off.
  "format-off": "",
  // Bluetooth hardware is disabled at the kernel/driver level.
  "format-disabled": "󰂲",
  // At least one device is connected.
  "format-connected": "󰂴",
  // Connected device reports battery level — show it alongside the icon.
  "format-connected-battery": "{device_battery_percentage}% 󰂴",
  // Base tooltip: controller name, MAC, and connection count.
  "tooltip-format": "{controller_alias}\t{controller_address}\n\n{num_connections} connected",
  // Extended tooltip listing each connected device when count > 0.
  "tooltip-format-connected": "{controller_alias}\t{controller_address}\n\n{num_connections} connected\n\n{device_enumerate}",
  // Per-device line in the enumeration: alias + MAC.
  "tooltip-format-enumerate-connected": "{device_alias}\t{device_address}",
  // Per-device line when battery info is available.
  "tooltip-format-enumerate-connected-battery": "{device_alias}\t{device_address}\t{device_battery_percentage}%",
  // Left-click launches rofi-bluetooth for a GUI device list.
  "on-click": "rofi-bluetooth",
 },



	// ── battery ─────────────────────────────────────────────
	// Shows remaining battery capacity and charging state.
	// 1-second interval so the "PWR-" / "PWR+" prefix switches instantly.
	"battery": {
    	"interval":1,
        // Named thresholds that trigger CSS state classes:
        //   .good     ≥ 95% (full — no visual warning)
        //   .warning  ≤ 30% (getting low)
        //   .critical ≤ 20% (nearly empty — style.css colors this bright red)
        "states": {
            "good": 95,
            "warning": 30,
            "critical": 20
        },
        // Discharging: "PWR-" prefix + capacity + level icon.
        "format": "PWR- {capacity}%  {icon} ",
        // Charging via AC: "PWR+" prefix + the charging glyph.
        "format-charging": "PWR+ {capacity}% 󰂄 ",
        // Plugged in at 100%: show charger icon even though full.
        "format-plugged": "PWR+ {capacity}% 󰂄 ",
        // Right-click (alt format) shows estimated time remaining.
        "format-alt": "{time} {icon}",
        // Six Nerd Font battery glyphs mapping roughly to 0→100% in steps.
        "format-icons": [
          		"󰁻",  // 0–20 %
          		"󰁼",  // 20–40 %
          		"󰁾",  // 40–60 %
          		"󰂀",  // 60–80 %
          		"󰂂",  // 80–95 %
          		"󰁹"   // 95–100 %
        ],
    },

// ── backlight ──────────────────────────────────────────────
// Screen brightness via the intel_backlight sysfs interface.
// Scroll wheel on this module adjusts brightness by ±10 units.
"backlight": {
  // Target the Intel integrated GPU backlight node specifically.
  "device": "intel_backlight",
  // Display only the icon — brightness level communicated visually.
  "format": "<span font='12'>{icon}</span>",
  // Ten sun/brightness Nerd Font icons mapping 0%→100% in 10% steps.
  "format-icons": [
    "",   // 0–10 %
    "",   // 10–20 %
    "",   // 20–30 %
    "",   // 30–40 %
    "",   // 40–50 %
    "",   // 50–60 %
    "",   // 60–70 %
    "",   // 70–80 %
    "",   // 80–90 %
    "",   // 90–100 %
  ],
  // Scroll down decreases brightness (note: flag names are swapped in `light`).
  "on-scroll-down": "light -A 10",
  // Scroll up increases brightness.
  "on-scroll-up": "light -U 10",
  // Threshold of 1 means no acceleration — every scroll tick = 10 units.
  "smooth-scrolling-threshold": 1
  },

 // ── disk ─────────────────────────────────────────────────
 // Shows how much of the root partition is used, as a percentage.
 // 30-second interval is fine — disk usage changes slowly.
 "disk": {
    "interval": 30,
    // Hard-drive Nerd Font glyph + used-space percentage.
    "format": "  {percentage_used}%",
    // Watch the root filesystem specifically (not /home or other mounts).
    "path": "/"
  },

  // ── custom/colorpicker ───────────────────────────────────
  // Wraps hyprpicker into a waybar button.
  // Clicking launches the eyedropper; the picked hex is copied to
  // clipboard and the module refreshes to show a colored dot.
  "custom/colorpicker": {
    // {} is replaced with the JSON "text" field from the script.
    "format": "{}",
    // Script returns {text, tooltip} JSON — waybar parses both fields.
    "return-type": "json",
    // "once" means only run at startup; RTMIN+1 triggers re-execution.
    "interval": "once",
    // On load: render the most-recently-picked color as a dot.
    "exec": "~/.config/waybar/scripts/colorpicker.sh -j",
    // Click: 1-second delay prevents the click from interfering with the
    // hyprpicker window, then launch the picker.
    "on-click": "sleep 1 && ~/.config/waybar/scripts/colorpicker.sh",
    // colorpicker.sh sends RTMIN+1 to waybar after saving a new color,
    // which causes this module to re-exec and show the new color.
    "signal": 1
  },

  // ── cpu ──────────────────────────────────────────────────
  // Aggregate CPU usage across all cores, updated every second.
  "cpu": {
      "interval": 1,
      // Nerd Font CPU chip icon + usage %. Fixed 6-char width stops the
      // bar from shifting when the value goes from single to double digits.
      "format": " {usage}%",
      "min-length": 6,
      "max-length": 6,
      // Bar-graph Unicode chars available for use in custom format strings.
      "format-icons": ["▁", "▂", "▃", "▄", "▅", "▆", "▇", "█"],
 },

// ── memory ────────────────────────────────────────────────
// RAM usage as a percentage. Compact single-field display.
"memory": {
  // Memory chip Nerd Font glyph + percentage of RAM used.
  "format": " {percentage}%"
},

 // ── hyprland/window ──────────────────────────────────────
 // Shows the WM_CLASS of the currently focused window in the bar center.
 // Rewrite rules transform noisy titles into cleaner short labels.
 "hyprland/window": {
    // Wrap the class name in parentheses for a "terminal prompt" aesthetic.
    "format": "( {class} )",
    "rewrite": {
         // Strip " - Mozilla Firefox" from page titles; prepend a globe.
         "(.*) - Mozilla Firefox": "🌎 $1",
         // Kitty/foot terminal: show the current directory in brackets.
         "(.*) - zsh": "> [$1]"
    }
},

// ── temperature ──────────────────────────────────────────
// CPU package temperature. Turns to a "critical" CSS class above 80 °C.
// Clicking opens btop for a full system-monitoring view.
"temperature": {
  // Normal state: thermometer glyph + temperature in Celsius.
  "format": " {temperatureC}°C",
  // Critical state: fire glyph replaces the thermometer icon.
  "format-critical": " {temperatureC}°C",
  // 1-second interval to catch sudden thermal spikes quickly.
  "interval": 1,
  // Above 80 °C the module switches to the "critical" CSS class.
  "critical-threshold": 80,
  // Left-click opens btop in the foot Wayland terminal.
  "on-click": "foot btop",
 },

// ── pulseaudio ───────────────────────────────────────────
// Volume level and mute control via PulseAudio or PipeWire-pulse.
// Left-click: toggle mute. Right-click: open pavucontrol GUI mixer.
"pulseaudio": {
  // Default format: percentage + device-type icon.
  "format": "{volume}% {icon}",
  // When the active sink is a Bluetooth device, show a BT-speaker glyph.
  "format-bluetooth":"󰂰",
  // Muted: show a crossed-speaker glyph, hide the volume number.
  "format-muted": "<span font='12'></span>",
  // Icon set keyed by audio device type reported by PulseAudio.
  "format-icons": {
    "headphones": "",
    "bluetooth": "󰥰",
    "handsfree": "",
    "headset": "󱡬",
    "phone": "",
    "portable": "",
    "car": "",
    // Default (built-in speaker): three-tier glyphs for low/mid/high volume.
    "default": ["󰕿","󰖀","󰕾"]
  },
  // Center-align the label within the module's allocated width.
  "justify": "center",
  // Toggle Master channel mute via amixer on left-click.
  "on-click": "amixer sset Master toggle",
  // Open the graphical PulseAudio volume control on right-click.
  "on-click-right": "pavucontrol",
  // Tooltip shows icon + volume % for a quick glance.
  "tooltip-format": "{icon}  {volume}%"
},

// ── jack ─────────────────────────────────────────────────
// JACK Audio Connection Kit DSP load monitor.
// Relevant when running pro-audio software that uses JACK directly.
"jack": {
    // {} = current DSP percentage (how busy the JACK graph is).
    "format": "{} 󱎔",
    // Xruns are buffer underruns — audio glitches. Non-zero = problem.
    "format-xrun": "{xruns} xruns",
    // JACK server is not running.
    "format-disconnected": "DSP off",
    // Poll in real-time (rather than on an interval) for accuracy.
    "realtime": true
},

// ── tray ────────────────────────────────────────────────
// System tray using the StatusNotifierItem / libdbusmenu protocol.
// Apps like NetworkManager applet, Blueman, etc. dock here.
"tray": {
    // Icon render size in pixels — 14 px is compact but readable.
    "icon-size": 14,
    // Horizontal gap between tray icons in pixels.
    "spacing": 10
},

// ── upower ──────────────────────────────────────────────
// Displays UPower-tracked peripheral battery levels (mice, keyboards).
// The icon is suppressed; info appears only in the tooltip to save space.
"upower": {
    // Don't show a persistent icon in the bar.
    "show-icon": false,
    // Collapse the module entirely when no UPower devices are present.
    "hide-if-empty": true,
    "tooltip": true,
    // Vertical spacing between device entries in the tooltip.
    "tooltip-spacing": 20
},


	// ── network ─────────────────────────────────────────────
	// Connection-type indicator: one icon for wifi, one for ethernet,
	// one for disconnected. Hovering reveals SSID, signal, or IP.
	"network":{
      // Wireless: show only a wifi Nerd Font glyph (no text).
      "format-wifi": " ",
      // Wired: ethernet cable Nerd Font glyph.
      "format-ethernet":" ",
      // Not connected to anything.
      "format-disconnected": "",
      // Ethernet tooltip: just the interface name (eth0, enp3s0, etc.).
      "tooltip-format": "{ifname}",
      // Wi-Fi tooltip: SSID, signal percentage, and IP address.
      "tooltip-format-wifi": "{essid} ({signalStrength}%)  | {ipaddr}",
      // Ethernet tooltip: interface name and IP address.
      "tooltip-format-ethernet": "{ifname} 🖧 | {ipaddr}"
	},

  // ── custom/powerDraw ─────────────────────────────────────
  // Reads instantaneous battery power draw in watts from sysfs.
  // Useful for identifying rogue processes spiking power consumption.
  "custom/powerDraw": {
    // {} replaced by the JSON "text" field from the script output.
    "format": "{}",
    // Poll every second — power draw is volatile.
    "interval": 1,
    // Script reads /sys/class/power_supply/BAT*/power_now and formats JSON.
    "exec": "~/.config/waybar/scripts/powerdraw.sh",
    // JSON return type lets the script provide both text and tooltip.
    "return-type": "json"
  }


}
