MCPcopy Create free account
hub / github.com/Recordscript/recordscript / system_message

Function system_message

libs/hbb_common/src/platform/linux.rs:259–294  ·  view source on GitHub ↗
(title: &str, msg: &str, forever: bool)

Source from the content-addressed store, hash-verified

257/// forever: may not work
258#[cfg(target_os = "linux")]
259pub fn system_message(title: &str, msg: &str, forever: bool) -> ResultType<()> {
260 let cmds: HashMap<&str, Vec<&str>> = HashMap::from([
261 ("notify-send", [title, msg].to_vec()),
262 (
263 "zenity",
264 [
265 "--info",
266 "--timeout",
267 if forever { "0" } else { "3" },
268 "--title",
269 title,
270 "--text",
271 msg,
272 ]
273 .to_vec(),
274 ),
275 ("kdialog", ["--title", title, "--msgbox", msg].to_vec()),
276 (
277 "xmessage",
278 [
279 "-center",
280 "-timeout",
281 if forever { "0" } else { "3" },
282 title,
283 msg,
284 ]
285 .to_vec(),
286 ),
287 ]);
288 for (k, v) in cmds {
289 if Command::new(k).args(v).spawn().is_ok() {
290 return Ok(());
291 }
292 }
293 crate::bail!("failed to post system message");
294}
295
296#[cfg(test)]
297mod tests {

Callers 2

breakdown_signal_handlerFunction · 0.85
mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected