Files
Matteo Benedetto 5528581848 feat: Tema sonoro Voyager per KDE Plasma
- index.theme con Directories=stereo, OutputProfile=stereo,
  Inherits=freedesktop ed Example=theme-demo
- 61 cue sintetizzati da zero (Ogg Vorbis 48 kHz stereo) piu' il montaggio
  di anteprima theme-demo.oga
- tools/gen_sounds.py: motore di sintesi riproducibile (radio a banda stretta
  con AM a onda quadra, quantizzazione a 7 bit, beep di telemetria, sweep)
- tools/verify_theme.py: verifica della spec, igiene audio (clipping, DC,
  click ai bordi) e copertura dei nomi suono richiesti dai notifyrc di KDE
- preview/index.html: player nel browser per ogni cue del tema
- Makefile, install.sh, LICENSES (audio CC-BY-SA-4.0, codice BSD-2-Clause)
2026-09-20 16:12:48 +02:00

59 lines
1.9 KiB
Python
Executable File

#!/usr/bin/env python3
# SPDX-License-Identifier: BSD-2-Clause
"""Generate preview/index.html for a sound theme."""
from __future__ import annotations
import shutil
import subprocess
import sys
from pathlib import Path
TEMPLATE = Path(__file__).with_name("preview_template.html")
def duration(path: Path) -> float:
ffp = shutil.which("ffprobe") or "ffprobe"
return float(subprocess.run(
[ffp, "-v", "error", "-show_entries", "format=duration",
"-of", "default=nw=1:nk=1", str(path)],
capture_output=True, text=True, check=True).stdout.strip())
def main() -> int:
theme = Path(sys.argv[1])
out = Path(sys.argv[2]) if len(sys.argv) > 2 else Path("preview/index.html")
files = sorted((theme / "stereo").glob("*.oga"))
names = ", ".join(f'["{f.stem}", {duration(f):.2f}]' for f in files
if f.stem != "theme-demo")
html = TEMPLATE.read_text(encoding="utf-8")
extra = {}
for cand in (Path("preview.meta"), theme.parent / "preview.meta",
theme / "preview.meta"):
if cand.is_file():
meta = cand
break
else:
meta = None
if meta is not None:
for line in meta.read_text(encoding="utf-8").splitlines():
if "=" in line and not line.startswith("#"):
k, v = line.split("=", 1)
extra[k.strip()] = v.strip()
extra.setdefault("title", theme.name)
extra.setdefault("tagline", "")
extra.setdefault("accent", "#2fb4d2")
extra.setdefault("accent2", "#70c493")
extra.setdefault("bg", "#0c1822")
extra.setdefault("fg", "#d7e6ee")
extra.setdefault("license", "CC BY-SA 4.0")
extra["names"] = "[ " + names + " ]"
extra["nsounds"] = str(len(files))
out.parent.mkdir(parents=True, exist_ok=True)
out.write_text(html.format(**extra), encoding="utf-8")
print(f"scritto {out} ({len(files)} cue)")
return 0
if __name__ == "__main__":
sys.exit(main())