From 5c9efcf316fc1fac08c9290ec165d9b6290146c0 Mon Sep 17 00:00:00 2001 From: Breadway Date: Wed, 17 Jun 2026 22:44:48 +0800 Subject: [PATCH] fix: correct awww subcommand to img, support bare path arg, add --version --- src/main.rs | 16 ++++++++++------ src/wallpaper.rs | 4 ++-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/main.rs b/src/main.rs index 38d3fc6..d108e3d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,17 +4,19 @@ use std::process; use clap::{Parser, Subcommand}; #[derive(Parser)] -#[command(name = "breadpaper", about = "Wallpaper manager for the bread desktop")] +#[command(name = "breadpaper", version, about = "Wallpaper manager for the bread desktop")] struct Cli { + /// Image file to set as wallpaper (shorthand for `set`) + path: Option, + #[command(subcommand)] - command: Command, + command: Option, } #[derive(Subcommand)] enum Command { /// Set wallpaper, generate pywal palette, and reload bread themes Set { - /// Path to the image file path: PathBuf, }, /// Print the current wallpaper path @@ -24,9 +26,11 @@ enum Command { fn main() { let cli = Cli::parse(); - let result = match cli.command { - Command::Set { path } => breadpaper::set(&path), - Command::Get => breadpaper::get().map(|p| println!("{}", p.display())), + let result = match (cli.command, cli.path) { + (Some(Command::Set { path }), _) | (None, Some(path)) => breadpaper::set(&path), + (Some(Command::Get), _) | (None, None) => { + breadpaper::get().map(|p| println!("{}", p.display())) + } }; if let Err(e) = result { diff --git a/src/wallpaper.rs b/src/wallpaper.rs index 4655308..f59fae1 100644 --- a/src/wallpaper.rs +++ b/src/wallpaper.rs @@ -5,13 +5,13 @@ use anyhow::{Context, Result, bail}; pub fn apply(path: &Path) -> Result<()> { let status = Command::new("awww") - .arg("set") + .arg("img") .arg(path) .status() .context("failed to run awww — is awww-daemon running?")?; if !status.success() { - bail!("awww set exited with {}", status); + bail!("awww img exited with {}", status); } Ok(()) }