From 74e8e58f3ca1c95b6dc1a7bfc2183a058d18071b Mon Sep 17 00:00:00 2001 From: szymon Date: Tue, 29 Sep 2026 15:08:52 +0200 Subject: [PATCH] feat: add get_app_name function --- src/functions.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/functions.rs b/src/functions.rs index 848f256..8c65c9a 100644 --- a/src/functions.rs +++ b/src/functions.rs @@ -35,6 +35,7 @@ where } /// Uninitializes libnotify. +/// /// This should be called when the program no longer needs libnotify for the rest of its lifecycle, typically just before exitting. pub fn uninit() { unsafe { @@ -47,10 +48,25 @@ pub fn is_initted() -> bool { unsafe { notify_is_initted() != 0 } } -/* Getting +/* Getters * */ +/// Gets the application name registered. +pub fn get_app_name() -> Option { + let app_name_c: *const std::os::raw::c_char = unsafe { notify_get_app_name() }; + + if app_name_c.is_null() { + return None; + } else { + Some( + unsafe { std::ffi::CStr::from_ptr(app_name_c) } + .to_string_lossy() + .to_string(), + ) + } +} + // Gets the application icon registered. // Available since: 0.8.4 pub fn get_app_icon() -> Option {