Timeout-guard the hyprctl monitors query
get_live_monitors used a bare Command::new("hyprctl").output() with no
timeout. Switched to bread_utils::proc::run_json, now that this crate
already depends on bread-utils (added in the config-migration commit).
This commit is contained in:
parent
f3a5839cf1
commit
041d927b00
1 changed files with 5 additions and 3 deletions
|
|
@ -69,11 +69,13 @@ fn save(rules: &[MonitorRule]) -> std::io::Result<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_live_monitors() -> Vec<(String, String)> {
|
fn get_live_monitors() -> Vec<(String, String)> {
|
||||||
let Ok(output) = std::process::Command::new("hyprctl").args(["monitors", "-j"]).output() else {
|
// Was a bare Command::new("hyprctl").output() with no timeout.
|
||||||
|
let Some(value) =
|
||||||
|
bread_utils::proc::run_json("hyprctl", &["monitors", "-j"], std::time::Duration::from_secs(3))
|
||||||
|
else {
|
||||||
return Vec::new();
|
return Vec::new();
|
||||||
};
|
};
|
||||||
let text = String::from_utf8_lossy(&output.stdout);
|
let Ok(monitors) = serde_json::from_value::<Vec<serde_json::Value>>(value) else {
|
||||||
let Ok(monitors) = serde_json::from_str::<Vec<serde_json::Value>>(&text) else {
|
|
||||||
return Vec::new();
|
return Vec::new();
|
||||||
};
|
};
|
||||||
monitors
|
monitors
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue