ZShell settings add

This commit is contained in:
2026-05-12 19:51:47 +02:00
parent 2903819626
commit 075cd42064
5 changed files with 27 additions and 175 deletions
-8
View File
@@ -6,7 +6,6 @@ use std::io::Write as _;
use std::process::{Command, Stdio};
fn main() -> Result<()> {
// ── 1. Collect image paths from CLI arguments ─────────────────────────────
let paths: Vec<String> = std::env::args().skip(1).collect();
if paths.is_empty() {
@@ -15,10 +14,8 @@ fn main() -> Result<()> {
std::process::exit(1);
}
// ── 2. Load config (generates default if missing) ─────────────────────────
let config = config::Config::load().context("Failed to load config")?;
// ── 3. Process each image ─────────────────────────────────────────────────
for path in &paths {
if let Err(e) = process_image(path, &config) {
eprintln!("Error processing '{}': {e:#}", path);
@@ -29,15 +26,12 @@ fn main() -> Result<()> {
}
fn process_image(path: &str, config: &config::Config) -> Result<()> {
// ── a. Load image ─────────────────────────────────────────────────────────
let img = image::open(path)
.with_context(|| format!("Failed to open image '{path}'"))?
.into_rgba8();
// ── b. Apply effects (rounded corners + drop shadow) ─────────────────────
let processed = effects::apply_effects(img, &config.effects);
// ── c. Encode as PNG into memory ──────────────────────────────────────────
let mut png_bytes: Vec<u8> = Vec::new();
image::DynamicImage::ImageRgba8(processed)
.write_to(
@@ -45,9 +39,7 @@ fn process_image(path: &str, config: &config::Config) -> Result<()> {
image::ImageFormat::Png,
)
.context("Failed to encode processed image as PNG")?;
// Re-unwrap into RgbaImage — not needed further, png_bytes is ready
// ── d. Pipe PNG bytes to `swappy -f -` ────────────────────────────────────
let mut child = Command::new("swappy")
.args(["-f", "-"])
.stdin(Stdio::piped())