Skip to main content

blocking_dialog/linux/
alert.rs

1// SPDX-FileCopyrightText: 2026 Manuel Quarneti <mq1@ik.me>
2// SPDX-License-Identifier: MIT OR Apache-2.0
3
4use crate::{BlockingAlertDialog, BlockingDialogError, BlockingDialogLevel};
5use std::process::Command;
6
7fn get_level_flag(level: BlockingDialogLevel) -> &'static str {
8    match level {
9        BlockingDialogLevel::Info => "--info",
10        BlockingDialogLevel::Warning => "--warning",
11        BlockingDialogLevel::Error => "--error",
12    }
13}
14
15impl<'a> BlockingAlertDialog<'a> {
16    pub fn show(&self) -> Result<(), BlockingDialogError> {
17        let level_flag = get_level_flag(self.level);
18
19        let _ = Command::new("zenity")
20            .arg(level_flag)
21            .arg("--title")
22            .arg(self.title)
23            .arg("--text")
24            .arg(self.message)
25            .status()?;
26
27        Ok(())
28    }
29}