bread-capture: write each app's captures into its own subfolder

Drops the app-name filename prefix (redundant with the folder name) —
output is now <out-dir>/<app>/<view>.png instead of a flat
<out-dir>/<app>-<view>.png. Makes browsing a multi-app run's output
directory clearer, and is what a real screenshots-folder deliverable
should look like.
This commit is contained in:
Breadway 2026-07-29 22:02:54 +08:00
parent 79d4d737cf
commit 7c7881ddf4

View file

@ -9,10 +9,11 @@
//! overrides where its binary is found (and, without `--app`, also selects //! overrides where its binary is found (and, without `--app`, also selects
//! which app by its file stem — so `--app-path ./target/release/breadbox` //! which app by its file stem — so `--app-path ./target/release/breadbox`
//! alone still works); `--view <name>` further restricts to one view. The //! alone still works); `--view <name>` further restricts to one view. The
//! view list for each app is looked up from [`TARGETS`] below. Flat output //! view list for each app is looked up from [`TARGETS`] below. Each app
//! directory for now — no versioned `screenshots/vX.Y.Z/latest` structure //! gets its own subdirectory under `--out-dir` (`<out-dir>/<app>/<view>.png`)
//! or manifest file yet, since that's still not earning its complexity over //! — no versioned `screenshots/vX.Y.Z/latest` structure or manifest file
//! a handful of apps. //! yet, since that's still not earning its complexity over a handful of
//! apps.
//! //!
//! By default every capture runs inside a throwaway headless Sway instance //! By default every capture runs inside a throwaway headless Sway instance
//! (see [`isolation`]) rather than the operator's live desktop, so another //! (see [`isolation`]) rather than the operator's live desktop, so another
@ -32,87 +33,89 @@ use std::time::Duration;
const CAPTURE_TIMEOUT: Duration = Duration::from_secs(10); const CAPTURE_TIMEOUT: Duration = Duration::from_secs(10);
/// Per-app (view name, output filename) lists. Keyed by the app's binary /// Per-app (view name, output filename) lists. Keyed by the app's binary
/// name — see `--app-name`. /// name — see `--app-name`. Filenames are plain (no app prefix): each app
/// gets its own subdirectory under `--out-dir` (`<out-dir>/<app>/<file>`),
/// so the prefix would just be redundant with the folder name.
const TARGETS: &[(&str, &[(&str, &str)])] = &[ const TARGETS: &[(&str, &[(&str, &str)])] = &[
( (
"breadbar", "breadbar",
&[ &[
("bar", "breadbar-bar.png"), ("bar", "bar.png"),
("control-panel", "breadbar-control-panel.png"), ("control-panel", "control-panel.png"),
("connectivity-wifi", "breadbar-connectivity-wifi.png"), ("connectivity-wifi", "connectivity-wifi.png"),
("connectivity-bluetooth", "breadbar-connectivity-bluetooth.png"), ("connectivity-bluetooth", "connectivity-bluetooth.png"),
("media-popover", "breadbar-media-popover.png"), ("media-popover", "media-popover.png"),
("notification", "breadbar-notification.png"), ("notification", "notification.png"),
("notification-critical", "breadbar-notification-critical.png"), ("notification-critical", "notification-critical.png"),
("osd-volume", "breadbar-osd-volume.png"), ("osd-volume", "osd-volume.png"),
("osd-brightness", "breadbar-osd-brightness.png"), ("osd-brightness", "osd-brightness.png"),
("wifi-add-dialog", "breadbar-wifi-add-dialog.png"), ("wifi-add-dialog", "wifi-add-dialog.png"),
], ],
), ),
("breadbox", &[("launcher", "breadbox-launcher.png")]), ("breadbox", &[("launcher", "launcher.png")]),
("breadclip", &[("history", "breadclip-history.png")]), ("breadclip", &[("history", "history.png")]),
("breadsearch", &[("search", "breadsearch-search.png")]), ("breadsearch", &[("search", "search.png")]),
( (
"breadpad", "breadpad",
&[ &[
("popup", "breadpad-popup.png"), ("popup", "popup.png"),
("reminder", "breadpad-reminder.png"), ("reminder", "reminder.png"),
("reminder-snooze", "breadpad-reminder-snooze.png"), ("reminder-snooze", "reminder-snooze.png"),
], ],
), ),
( (
"breadhelp", "breadhelp",
&[ &[
("home", "breadhelp-home.png"), ("home", "home.png"),
("learn", "breadhelp-learn.png"), ("learn", "learn.png"),
("ask", "breadhelp-ask.png"), ("ask", "ask.png"),
("troubleshoot-wizard", "breadhelp-troubleshoot-wizard.png"), ("troubleshoot-wizard", "troubleshoot-wizard.png"),
], ],
), ),
( (
"breadman", "breadman",
&[ &[
("all", "breadman-all.png"), ("all", "all.png"),
("upcoming", "breadman-upcoming.png"), ("upcoming", "upcoming.png"),
("todo", "breadman-todo.png"), ("todo", "todo.png"),
("reminder", "breadman-reminder.png"), ("reminder", "reminder.png"),
("idea", "breadman-idea.png"), ("idea", "idea.png"),
("note", "breadman-note.png"), ("note", "note.png"),
("question", "breadman-question.png"), ("question", "question.png"),
("archive", "breadman-archive.png"), ("archive", "archive.png"),
("settings", "breadman-settings.png"), ("settings", "settings.png"),
("errors", "breadman-errors.png"), ("errors", "errors.png"),
("editor", "breadman-editor.png"), ("editor", "editor.png"),
("new-note", "breadman-new-note.png"), ("new-note", "new-note.png"),
], ],
), ),
( (
"bos-settings", "bos-settings",
&[ &[
("network", "bos-settings-network.png"), ("network", "network.png"),
("breadcrumbs", "bos-settings-breadcrumbs.png"), ("breadcrumbs", "breadcrumbs.png"),
("bluetooth", "bos-settings-bluetooth.png"), ("bluetooth", "bluetooth.png"),
("firewall", "bos-settings-firewall.png"), ("firewall", "firewall.png"),
("sound", "bos-settings-sound.png"), ("sound", "sound.png"),
("power", "bos-settings-power.png"), ("power", "power.png"),
("datetime", "bos-settings-datetime.png"), ("datetime", "datetime.png"),
("hyprland", "bos-settings-hyprland.png"), ("hyprland", "hyprland.png"),
("keybinds", "bos-settings-keybinds.png"), ("keybinds", "keybinds.png"),
("autostart", "bos-settings-autostart.png"), ("autostart", "autostart.png"),
("users", "bos-settings-users.png"), ("users", "users.png"),
("appearance", "bos-settings-appearance.png"), ("appearance", "appearance.png"),
("breadpaper", "bos-settings-breadpaper.png"), ("breadpaper", "breadpaper.png"),
("breadbar", "bos-settings-breadbar.png"), ("breadbar", "breadbar.png"),
("breadbox", "bos-settings-breadbox.png"), ("breadbox", "breadbox.png"),
("breadclip", "bos-settings-breadclip.png"), ("breadclip", "breadclip.png"),
("breadpad", "bos-settings-breadpad.png"), ("breadpad", "breadpad.png"),
("breadsearch", "bos-settings-breadsearch.png"), ("breadsearch", "breadsearch.png"),
("bread", "bos-settings-bread.png"), ("bread", "bread.png"),
("packages", "bos-settings-packages.png"), ("packages", "packages.png"),
("aur", "bos-settings-aur.png"), ("aur", "aur.png"),
("firmware", "bos-settings-firmware.png"), ("firmware", "firmware.png"),
("snapshots", "bos-settings-snapshots.png"), ("snapshots", "snapshots.png"),
("about", "bos-settings-about.png"), ("about", "about.png"),
], ],
), ),
]; ];
@ -223,7 +226,7 @@ fn main() -> Result<ExitCode> {
if cli.view.as_deref().is_some_and(|v| v != *view) { if cli.view.as_deref().is_some_and(|v| v != *view) {
continue; continue;
} }
let out_path = cli.out_dir.join(filename); let out_path = cli.out_dir.join(app_name).join(filename);
let out_str = out_path.to_string_lossy(); let out_str = out_path.to_string_lossy();
let result = bread_utils::proc::run( let result = bread_utils::proc::run(
app_path, app_path,