Files
Nomarchy/modules/home/osd.nix
Bernardo Magri 520c878bb3 feat: swayosd on-screen display for volume/brightness/mute
The media keys called wpctl/brightnessctl directly with no visual
feedback — changing volume showed nothing on screen. Now they drive
swayosd-client, which performs the action AND shows a themed OSD.

- modules/home/osd.nix: services.swayosd, style.css generated from the
  palette (base bg, accent progress/border); nomarchy.osd.enable.
- hyprland media binds → swayosd-client (--output-volume raise/lower/
  mute-toggle, --input-volume mute-toggle, --brightness raise/lower).
- modules/nixos: services.udev.packages = [ swayosd ] installs the
  backlight rule (chgrp video + g+w) so brightness works for video-group
  users without root (the installer/live user is in video).

swaync is unaffected (it was already running — this was purely the
missing OSD). Verified: flake check green, swayosd.service bound to
graphical-session.target, hyprland config verifies, swayosd in the live
ISO closure. On-screen rendering needs a real session to confirm.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-13 16:04:55 +01:00

56 lines
1.5 KiB
Nix

# 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;
};
};
}