# swayosd — on-screen display for volume / brightness / mute (and caps
# lock). The media keys drive it via swayosd-client (it performs the
# action AND shows the OSD), so changing volume or brightness gives the
# visual feedback that bare wpctl/brightnessctl didn't. Themed from
# theme-state.json. Brightness needs the backlight udev rule shipped
# system-side (modules/nixos/default.nix → services.udev.packages).
{ config, lib, pkgs, ... }:

let
  cfg = config.nomarchy;
  t = cfg.theme;
  c = t.colors;

  style = pkgs.writeText "swayosd-style.css" ''
    window#osd {
      border-radius: ${toString t.ui.rounding}px;
      border: ${toString t.ui.borderSize}px solid ${c.accent};
      background: alpha(${c.base}, 0.92);
    }
    window#osd #container { margin: 16px; }
    window#osd image,
    window#osd label { color: ${c.text}; }
    window#osd progressbar:disabled,
    window#osd image:disabled { opacity: 0.5; }
    window#osd progressbar,
    window#osd segmentedprogress {
      min-height: 8px;
      border-radius: 999px;
      background: transparent;
      border: none;
    }
    window#osd trough,
    window#osd segment {
      min-height: inherit;
      border-radius: inherit;
      border: none;
      background: ${c.surface};
    }
    window#osd progress,
    window#osd segment.active {
      min-height: inherit;
      border-radius: inherit;
      border: none;
      background: ${c.accent};
    }
  '';
in
{
  config = lib.mkIf cfg.osd.enable {
    services.swayosd = {
      enable = true;
      stylePath = style;
    };
  };
}
