From d8bfa0a1a3d2c67730b7febb3c1d7a4d498bd417 Mon Sep 17 00:00:00 2001 From: Michael Yang Date: Sat, 6 Jul 2024 17:24:33 +1000 Subject: [PATCH] feat: add systemd notify with feature --- Cargo.lock | 7 +++++++ Cargo.toml | 6 ++++++ src/lib.rs | 3 +++ 3 files changed, 16 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 7050da3..779d96c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -464,6 +464,12 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" +[[package]] +name = "sd-notify" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4646d6f919800cd25c50edb49438a1381e2cd4833c027e75e8897981c50b8b5e" + [[package]] name = "shlex" version = "1.3.0" @@ -856,6 +862,7 @@ dependencies = [ "paste", "pretty_env_logger", "rustix", + "sd-notify", "slotmap", "smithay-client-toolkit", "testwl", diff --git a/Cargo.toml b/Cargo.toml index ea3dcae..d34bf94 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,6 +34,12 @@ slotmap = "1.0.7" xcb-util-cursor = "0.3.2" smithay-client-toolkit = { version = "0.19.1", default-features = false } +sd-notify = { version = "0.4.2", optional = true } + +[features] +default = [] +systemd = ["dep:sd-notify"] + [dev-dependencies] rustix = { workspace = true, features = ["fs"] } testwl = { path = "testwl" } diff --git a/src/lib.rs b/src/lib.rs index e9f7d8b..b8fe5b7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -158,6 +158,9 @@ pub fn main(data: impl RunData) -> Option<()> { data.xwayland_ready(display); server_state.set_x_connection(xstate.connection.clone()); server_state.atoms = Some(xstate.atoms.clone()); + + #[cfg(feature = "systemd")] + let _ = sd_notify::notify(true, &[sd_notify::NotifyState::Ready]); } if let Some(xstate) = &mut xstate {