56 lines
1.8 KiB
Rust
56 lines
1.8 KiB
Rust
use std::path::PathBuf;
|
|
|
|
use moon_plasma_host::compositor::MoonPlasmaCompositor;
|
|
use moon_plasma_host::renderer::SoftwareRenderer;
|
|
use moon_plasma_host::theme::ThemeTokens;
|
|
|
|
fn main() -> anyhow::Result<()> {
|
|
let args: Vec<String> = std::env::args().collect();
|
|
let mut out_path = PathBuf::from("frame.png");
|
|
let mut socket_path = PathBuf::from("/tmp/moon-plasma-wayland-0");
|
|
let mut components_dir = PathBuf::from("../build/components");
|
|
let mut theme_path = PathBuf::from("../config/themes/moon-night.json");
|
|
|
|
let mut i = 1;
|
|
while i < args.len() {
|
|
match args[i].as_str() {
|
|
"--out" if i + 1 < args.len() => {
|
|
out_path = PathBuf::from(&args[i + 1]);
|
|
i += 2;
|
|
}
|
|
"--socket" if i + 1 < args.len() => {
|
|
socket_path = PathBuf::from(&args[i + 1]);
|
|
i += 2;
|
|
}
|
|
"--components" if i + 1 < args.len() => {
|
|
components_dir = PathBuf::from(&args[i + 1]);
|
|
i += 2;
|
|
}
|
|
"--theme" if i + 1 < args.len() => {
|
|
theme_path = PathBuf::from(&args[i + 1]);
|
|
i += 2;
|
|
}
|
|
_ => i += 1,
|
|
}
|
|
}
|
|
|
|
let theme = if theme_path.exists() {
|
|
ThemeTokens::load_file(&theme_path)?
|
|
} else {
|
|
ThemeTokens::moon_night_default()
|
|
};
|
|
|
|
let mut compositor = MoonPlasmaCompositor::new(&socket_path, &components_dir, theme, 1280, 720)?;
|
|
compositor.step()?;
|
|
let pixmap = compositor.compose_frame()?;
|
|
SoftwareRenderer::save_png(&pixmap, &out_path)?;
|
|
println!(
|
|
"moon-plasma-host: Wayland socket={}, rendered {}x{} frame to {}",
|
|
socket_path.display(),
|
|
pixmap.width(),
|
|
pixmap.height(),
|
|
out_path.display()
|
|
);
|
|
Ok(())
|
|
}
|