diff --git a/libtiny_tui/Cargo.toml b/libtiny_tui/Cargo.toml index acb52eb1..756e83d5 100644 --- a/libtiny_tui/Cargo.toml +++ b/libtiny_tui/Cargo.toml @@ -4,12 +4,16 @@ version = "0.1.0" description = "A terminal UI for tiny" edition = "2018" +[features] +default = ["desktop-notifications"] +desktop-notifications = ["notify-rust"] + [dependencies] env_logger = "0.7" futures = "0.3.1" libtiny_ui = { path = "../libtiny_ui" } log = "0.4" -notify-rust = "3" +notify-rust = { version = "3", optional = true } serde = { version = "1.0.8", features = ["derive"] } serde_yaml = "0.7.1" tempfile = "3.0.3" diff --git a/libtiny_tui/src/notifier.rs b/libtiny_tui/src/notifier.rs index fb29fc99..46397214 100644 --- a/libtiny_tui/src/notifier.rs +++ b/libtiny_tui/src/notifier.rs @@ -1,4 +1,6 @@ use crate::{utils::remove_irc_control_chars, MsgTarget}; + +#[cfg(feature = "desktop-notifications")] use notify_rust::Notification; /// Destktop notification handler @@ -12,11 +14,15 @@ pub(crate) enum Notifier { Messages, } +#[cfg(feature = "desktop-notifications")] fn notify(summary: &str, body: &str) { // TODO: Report errors somehow let _ = Notification::new().summary(summary).body(body).show(); } +#[cfg(not(feature = "desktop-notifications"))] +fn notify(_summary: &str, _body: &str) {} + impl Notifier { pub(crate) fn notify_privmsg( &mut self, diff --git a/tiny/Cargo.toml b/tiny/Cargo.toml index b4708361..ca04957c 100644 --- a/tiny/Cargo.toml +++ b/tiny/Cargo.toml @@ -9,9 +9,10 @@ description = "An IRC client" edition = "2018" [features] -default = ["tls-native"] +default = ["tls-native", "desktop-notifications"] tls-native = ["libtiny_client/tls-native"] tls-rustls = ["libtiny_client/tls-rustls"] +desktop-notifications = ["libtiny_tui/desktop-notifications"] [dependencies] dirs = "1.0.2" @@ -19,7 +20,7 @@ env_logger = "0.7" futures = "0.3.1" libtiny_client = { path = "../libtiny_client", default-features = false } libtiny_logger = { path = "../libtiny_logger" } -libtiny_tui = { path = "../libtiny_tui" } +libtiny_tui = { path = "../libtiny_tui", default-features = false } libtiny_ui = { path = "../libtiny_ui" } libtiny_wire = { path = "../libtiny_wire" } log = "0.4"