Timeout-guard hyprctl JSON queries
hyprctl_json used a bare Command::new("hyprctl").output() with no timeout,
used by every geometry_* helper (region/output/window/active_window/
active_output selection) — an unresponsive hyprctl could block screenshot
capture indefinitely. Switched to bread_utils::proc::run_json (path
dependency for now, see the TODO in Cargo.toml).
grim/slurp/wl-copy calls deliberately left untouched: several pipe binary
image data through stdin/stdout (e.g. grim -> wl-copy), which
bread_utils::proc's current run_with_stdin only accepts as &str — adapting
those safely would need a bytes-flavored variant, out of scope for this
pass to avoid risking a regression in image piping.
This commit is contained in:
parent
08c27d1b22
commit
5e4cbc83c9
3 changed files with 15 additions and 6 deletions
|
|
@ -303,12 +303,9 @@ fn send_notification(title: &str, msg: &str, timeout: u32, path: &Path) {
|
|||
// --- helpers ---
|
||||
|
||||
fn hyprctl_json(subcmd: &str) -> Result<Value> {
|
||||
let out = Command::new("hyprctl")
|
||||
.args(["-j", subcmd])
|
||||
.output()
|
||||
.context("running hyprctl")?;
|
||||
serde_json::from_slice(&out.stdout)
|
||||
.with_context(|| format!("parsing hyprctl {subcmd} output"))
|
||||
// Was a bare Command::new("hyprctl").output() with no timeout.
|
||||
bread_utils::proc::run_json("hyprctl", &["-j", subcmd], std::time::Duration::from_secs(3))
|
||||
.with_context(|| format!("running/parsing hyprctl {subcmd}"))
|
||||
}
|
||||
|
||||
fn slurp(args: &[&str]) -> Result<String> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue