Skip to content

Commit

Permalink
Make desktop notifications feature (dbus) optional
Browse files Browse the repository at this point in the history
With this I can make a statically linked executable with

    $ cargo build --target=x86_64-unknown-linux-musl \
        --no-default-features --features tls-rustls

The generated executable does not support generating desktop
notifications and uses rustls instead of libssl.

(#65)
  • Loading branch information
osa1 committed Jan 29, 2020
1 parent 334fe35 commit 1818293
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
6 changes: 5 additions & 1 deletion libtiny_tui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 6 additions & 0 deletions libtiny_tui/src/notifier.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use crate::{utils::remove_irc_control_chars, MsgTarget};

#[cfg(feature = "desktop-notifications")]
use notify_rust::Notification;

/// Destktop notification handler
Expand All @@ -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,
Expand Down
5 changes: 3 additions & 2 deletions tiny/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,18 @@ 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"
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"
Expand Down

0 comments on commit 1818293

Please sign in to comment.