rustdesk
2025-08-14 18:47:52 +08:00
parent 212bbaf44c
commit 16d301a783
4 changed files with 38 additions and 2 deletions

View File

@@ -25,7 +25,7 @@ use hbb_common::{
};
use include_dir::{include_dir, Dir};
use objc::rc::autoreleasepool;
use objc::{class, msg_send, sel, sel_impl};
use objc::{class, msg_send, runtime::Object, sel, sel_impl};
use scrap::{libc::c_void, quartz::ffi::*};
use std::{
collections::HashMap,
@@ -171,6 +171,7 @@ pub fn is_installed_daemon(prompt: bool) -> bool {
let agent = format!("{}_server.plist", crate::get_full_name());
let agent_plist_file = format!("/Library/LaunchAgents/{}", agent);
if !prompt {
// in macos 13, there is new way to check if they are running or enabled, https://developer.apple.com/documentation/servicemanagement/updating-helper-executables-from-earlier-versions-of-macos#Respond-to-changes-in-System-Settings
if !std::path::Path::new(&format!("/Library/LaunchDaemons/{}", daemon)).exists() {
return false;
}
@@ -296,6 +297,9 @@ fn update_daemon_agent(agent_plist_file: String, update_source_dir: String, sync
fn correct_app_name(s: &str) -> String {
let s = s.replace("rustdesk", &crate::get_app_name().to_lowercase());
let s = s.replace("RustDesk", &crate::get_app_name());
if let Some(bundleid) = get_bundle_id() {
let s = s.replace("com.carriez.rustdesk", &bundleid);
}
s
}
@@ -1052,3 +1056,27 @@ impl WakeLock {
.ok_or(anyhow!("no AwakeHandle"))?
}
}
fn get_bundle_id() -> Option<String> {
unsafe {
let bundle: id = msg_send![class!(NSBundle), mainBundle];
if bundle.is_null() {
return None;
}
let bundle_id: id = msg_send![bundle, bundleIdentifier];
if bundle_id.is_null() {
return None;
}
let c_str: *const std::os::raw::c_char = msg_send![bundle_id, UTF8String];
if c_str.is_null() {
return None;
}
let bundle_id_str = std::ffi::CStr::from_ptr(c_str)
.to_string_lossy()
.to_string();
Some(bundle_id_str)
}
}

View File

@@ -4,6 +4,10 @@
<dict>
<key>Label</key>
<string>com.carriez.RustDesk_server</string>
<key>AssociatedBundleIdentifiers</key>
<string>com.carriez.rustdesk</string>
<key>LimitLoadToSessionType</key>
<array>
<string>LoginWindow</string>

View File

@@ -4,6 +4,10 @@
<dict>
<key>Label</key>
<string>com.carriez.RustDesk_service</string>
<key>AssociatedBundleIdentifiers</key>
<string>com.carriez.rustdesk</string>
<key>KeepAlive</key>
<true/>
<key>ThrottleInterval</key>