Extract bos-settings to its own repo; add breadhelp; JSON-driven Hyprland config

bos-settings moves to git.breadway.dev/Breadway/bos-settings (full history
preserved via git-filter-repo) so its release cadence is decoupled from
BOS's own. breadhelp takes its place as this repo's workspace member: a
GTK4 onboarding/help center replacing the old bos-welcome/bos-keybinds
bash scripts with searchable guides, an interactive keybind viewer
(sourced from the new keybinds.toml, not parsed out of hyprland.lua or
hardcoded), a troubleshooting wizard with one-click fixes, and a proper
first-run tour. bos-netcheck extracts bos-welcome's network-check half,
which still needs to run every login independent of breadhelp's own
first-run gating.

hyprland.lua's keybinds/settings/monitors/autostart are now JSON-driven
(binds.json/settings.json/monitors.json/autostart.json) with every
loader pcall-wrapped and falling back to hardcoded defaults per field on
bad or missing config, so bread* apps (bos-settings' new editors, and
breadhelp's keybind viewer) can read/write this config without ever
being able to leave the compositor unable to start.

CI's package.yml now builds breadhelp instead of bos-settings on tag
push; bos-settings needs its own equivalent workflow in its new repo
(not yet set up).
This commit is contained in:
Breadway 2026-07-05 09:16:14 +08:00
commit fea8f83204
50 changed files with 2403 additions and 0 deletions

16
src/services/breadd.rs Normal file
View file

@ -0,0 +1,16 @@
//! Maps a `--suggest <id>` payload (sent by a breadd Lua module, e.g.
//! `breadhelp-suggest.lua` reacting to `bread.monitor.connected`) to Home
//! tab banner text.
pub struct Suggestion {
pub text: String,
}
pub fn resolve(id: &str) -> Option<Suggestion> {
match id {
"monitor-setup" => Some(Suggestion {
text: "New monitor detected — want to set up your display layout?".to_string(),
}),
_ => None,
}
}

28
src/services/exec.rs Normal file
View file

@ -0,0 +1,28 @@
use std::process::Command;
/// Fire-and-forget: runs `command` via a shell, matching the idiom already
/// used throughout bos-settings' views (`let _ = Command::new(...).spawn()`).
pub fn run(command: &str) {
if let Err(e) = Command::new("sh").arg("-c").arg(command).spawn() {
eprintln!("breadhelp: failed to run `{command}`: {e}");
}
}
/// Runs `command` on a background thread and delivers success/failure back
/// onto the GTK main loop via `on_done` — plain `spawn()` only confirms the
/// process *launched*, not how it exited, and one-click fixes need to report
/// that back to the user (a toast), so this blocks a throwaway thread on
/// `Command::status()` instead of the UI thread.
pub fn run_reporting(command: &str, on_done: impl Fn(bool) + 'static) {
let command = command.to_string();
let (tx, rx) = async_channel::bounded(1);
std::thread::spawn(move || {
let status = Command::new("sh").arg("-c").arg(&command).status();
let _ = tx.send_blocking(status.map(|s| s.success()).unwrap_or(false));
});
glib::MainContext::default().spawn_local(async move {
if let Ok(success) = rx.recv().await {
on_done(success);
}
});
}

15
src/services/hyprland.rs Normal file
View file

@ -0,0 +1,15 @@
use std::process::Command;
/// Runtime-only rebind via `hyprctl keyword bind`: takes effect immediately
/// and resets on the next Hyprland reload/login. `hyprland.lua` can't safely
/// be rewritten line-by-line by a program (hand-authored Lua, arbitrary
/// formatting), so this is the only rebind path — callers must label it
/// clearly as temporary in the UI.
///
/// `bind_value` is the full `<mods>,<key>,<dispatcher>,<args>` string, e.g.
/// `"SUPER,U,exec,breadpad"`.
pub fn rebind_temp(bind_value: &str) {
if let Err(e) = Command::new("hyprctl").args(["keyword", "bind", bind_value]).spawn() {
eprintln!("breadhelp: hyprctl rebind failed: {e}");
}
}

3
src/services/mod.rs Normal file
View file

@ -0,0 +1,3 @@
pub mod breadd;
pub mod exec;
pub mod hyprland;