Initial implementation of breadpaper
Some checks failed
Mirror to GitHub / mirror (push) Failing after 2s
Build and publish package / package (push) Failing after 1m3s

CLI tool that sets a wallpaper with awww, generates a pywal colour
palette, and reloads bread-theme to recolour all running bread GTK apps.
Includes CI workflows, bakery metadata, and Arch PKGBUILD.
This commit is contained in:
Breadway 2026-06-17 14:05:48 +08:00
commit a8b38597ff
14 changed files with 548 additions and 0 deletions

61
src/lib.rs Normal file
View file

@ -0,0 +1,61 @@
mod pywal;
mod theme;
mod wallpaper;
use std::path::{Path, PathBuf};
use anyhow::{Context, Result, bail};
const IMAGE_EXTENSIONS: &[&str] = &["png", "jpg", "jpeg", "webp", "gif", "bmp"];
pub fn set(path: &Path) -> Result<()> {
let path = validate(path)?;
apply_wallpaper(&path)?;
generate_palette(&path)?;
reload_theme()?;
Ok(())
}
pub fn get() -> Result<PathBuf> {
let home = std::env::var("HOME").context("HOME not set")?;
let wal_file = PathBuf::from(home).join(".cache/wal/wal");
let contents = std::fs::read_to_string(&wal_file)
.with_context(|| format!("no wallpaper set yet ({})", wal_file.display()))?;
Ok(PathBuf::from(contents.trim()))
}
pub fn apply_wallpaper(path: &Path) -> Result<()> {
wallpaper::apply(path)
}
pub fn generate_palette(path: &Path) -> Result<()> {
pywal::generate(path)
}
pub fn reload_theme() -> Result<()> {
theme::reload()
}
fn validate(path: &Path) -> Result<PathBuf> {
let canonical = path
.canonicalize()
.with_context(|| format!("not found: {}", path.display()))?;
let ext = canonical
.extension()
.and_then(|e| e.to_str())
.unwrap_or("")
.to_lowercase();
if !IMAGE_EXTENSIONS.contains(&ext.as_str()) {
bail!(
"unsupported file type '.{}' — expected one of: {}",
ext,
IMAGE_EXTENSIONS.join(", ")
);
}
Ok(canonical)
}