Skip to content

An open-source remote desktop application designed for self-hosting, as an alternative to TeamViewer.

hide-tray option

rustdesk2f432e941dda
diff --git a/libs/hbb_common/src/config.rs b/libs/hbb_common/src/config.rs
index ff6de4430..0a884e1f8 100644
--- a/libs/hbb_common/src/config.rs
+++ b/libs/hbb_common/src/config.rs
@@ -69,7 +69,7 @@ lazy_static::lazy_static! {
pub static ref DEFAULT_LOCAL_SETTINGS: RwLock<HashMap<String, String>> = Default::default();
pub static ref OVERWRITE_LOCAL_SETTINGS: RwLock<HashMap<String, String>> = Default::default();
pub static ref HARD_SETTINGS: RwLock<HashMap<String, String>> = Default::default();
- pub static ref BUILDIN_SETTINGS: RwLock<HashMap<String, String>> = Default::default();
+ pub static ref BUILTIN_SETTINGS: RwLock<HashMap<String, String>> = Default::default();
}
lazy_static::lazy_static! {
@@ -2114,6 +2114,7 @@ pub mod keys {
pub const OPTION_HIDE_USERNAME_ON_CARD: &str = "hide-username-on-card";
pub const OPTION_HIDE_HELP_CARDS: &str = "hide-help-cards";
pub const OPTION_DEFAULT_CONNECT_PASSWORD: &str = "default-connect-password";
+ pub const OPTION_HIDE_TRAY: &str = "hide-tray";
// flutter local options
pub const OPTION_FLUTTER_REMOTE_MENUBAR_STATE: &str = "remoteMenubarState";
@@ -2256,6 +2257,7 @@ pub mod keys {
OPTION_HIDE_USERNAME_ON_CARD,
OPTION_HIDE_HELP_CARDS,
OPTION_DEFAULT_CONNECT_PASSWORD,
+ OPTION_HIDE_TRAY,
];
}
diff --git a/src/client.rs b/src/client.rs
index 48e8033b9..ec85f4807 100644
--- a/src/client.rs
+++ b/src/client.rs
@@ -65,7 +65,7 @@ use crate::{
check_port,
common::input::{MOUSE_BUTTON_LEFT, MOUSE_BUTTON_RIGHT, MOUSE_TYPE_DOWN, MOUSE_TYPE_UP},
create_symmetric_key_msg, decode_id_pk, get_rs_pk, is_keyboard_mode_supported, secure_tcp,
- ui_interface::{get_buildin_option, use_texture_render},
+ ui_interface::{get_builtin_option, use_texture_render},
ui_session_interface::{InvokeUiSession, Session},
};
@@ -2137,7 +2137,7 @@ impl LoginConfigHandler {
} else {
(my_id, self.id.clone())
};
- let mut display_name = get_buildin_option(config::keys::OPTION_DISPLAY_NAME);
+ let mut display_name = get_builtin_option(config::keys::OPTION_DISPLAY_NAME);
if display_name.is_empty() {
display_name =
serde_json::from_str::<serde_json::Value>(&LocalConfig::get_option("user_info"))
@@ -2920,7 +2920,7 @@ pub async fn handle_hash(
if password.is_empty() {
let p =
- crate::ui_interface::get_buildin_option(config::keys::OPTION_DEFAULT_CONNECT_PASSWORD);
+ crate::ui_interface::get_builtin_option(config::keys::OPTION_DEFAULT_CONNECT_PASSWORD);
if !p.is_empty() {
let mut hasher = Sha256::new();
hasher.update(p.clone());
diff --git a/src/common.rs b/src/common.rs
index 740b5d9e3..108d25659 100644
--- a/src/common.rs
+++ b/src/common.rs
@@ -1359,7 +1359,7 @@ fn read_custom_client_advanced_settings(
} else {
config::DEFAULT_SETTINGS.write().unwrap()
};
- let mut buildin_settings = config::BUILDIN_SETTINGS.write().unwrap();
+ let mut buildin_settings = config::BUILTIN_SETTINGS.write().unwrap();
if let Some(settings) = settings.as_object() {
for (k, v) in settings {
diff --git a/src/flutter_ffi.rs b/src/flutter_ffi.rs
index 08e79cbea..cceec4cd1 100644
--- a/src/flutter_ffi.rs
+++ b/src/flutter_ffi.rs
@@ -2220,7 +2220,7 @@ pub fn main_get_hard_option(key: String) -> SyncReturn<String> {
}
pub fn main_get_buildin_option(key: String) -> SyncReturn<String> {
- SyncReturn(get_buildin_option(&key))
+ SyncReturn(get_builtin_option(&key))
}
pub fn main_check_hwcodec() {
diff --git a/src/hbbs_http/sync.rs b/src/hbbs_http/sync.rs
index f2717a42c..91c18c4b2 100644
--- a/src/hbbs_http/sync.rs
+++ b/src/hbbs_http/sync.rs
@@ -5,7 +5,7 @@ use std::{
};
#[cfg(not(any(target_os = "ios")))]
-use crate::{ui_interface::get_buildin_option, Connection};
+use crate::{ui_interface::get_builtin_option, Connection};
use hbb_common::{
config::{keys, Config, LocalConfig},
tokio::{self, sync::broadcast, time::Instant},
@@ -91,11 +91,11 @@ async fn start_hbbs_sync_async() {
if !ab_tag.is_empty() {
v[keys::OPTION_PRESET_ADDRESS_BOOK_TAG] = json!(ab_tag);
}
- let username = get_buildin_option(keys::OPTION_PRESET_USERNAME);
+ let username = get_builtin_option(keys::OPTION_PRESET_USERNAME);
if !username.is_empty() {
v[keys::OPTION_PRESET_USERNAME] = json!(username);
}
- let strategy_name = get_buildin_option(keys::OPTION_PRESET_STRATEGY_NAME);
+ let strategy_name = get_builtin_option(keys::OPTION_PRESET_STRATEGY_NAME);
if !strategy_name.is_empty() {
v[keys::OPTION_PRESET_STRATEGY_NAME] = json!(strategy_name);
}
diff --git a/src/rendezvous_mediator.rs b/src/rendezvous_mediator.rs
index 65bb6a2b3..4ae222966 100644
--- a/src/rendezvous_mediator.rs
+++ b/src/rendezvous_mediator.rs
@@ -32,7 +32,7 @@ use hbb_common::{
use crate::{
check_port,
server::{check_zombie, new as new_server, ServerPtr},
- ui_interface::get_buildin_option,
+ ui_interface::get_builtin_option,
};
type Message = RendezvousMessage;
@@ -391,7 +391,7 @@ impl RendezvousMediator {
};
if (cfg!(debug_assertions) && option_env!("TEST_TCP").is_some())
|| is_http_proxy
- || get_buildin_option(config::keys::OPTION_DISABLE_UDP) == "Y"
+ || get_builtin_option(config::keys::OPTION_DISABLE_UDP) == "Y"
{
Self::start_tcp(server, host).await
} else {
diff --git a/src/tray.rs b/src/tray.rs
index 18d6d7e91..4b30c7e08 100644
--- a/src/tray.rs
+++ b/src/tray.rs
@@ -9,6 +9,16 @@ use std::sync::{Arc, Mutex};
use std::time::Duration;
pub fn start_tray() {
+ if crate::ui_interface::get_builtin_option(hbb_common::config::keys::OPTION_HIDE_TRAY) == "Y" {
+ if cfg!(target_os = "macos") {
+ crate::platform::macos::hide_dock();
+ loop {
+ std::thread::sleep(std::time::Duration::from_secs(1));
+ }
+ } else {
+ return;
+ }
+ }
allow_err!(make_tray());
}
diff --git a/src/ui_interface.rs b/src/ui_interface.rs
index a192265df..443f6fa42 100644
--- a/src/ui_interface.rs
+++ b/src/ui_interface.rs
@@ -206,8 +206,8 @@ pub fn get_hard_option(key: String) -> String {
}
#[inline]
-pub fn get_buildin_option(key: &str) -> String {
- config::BUILDIN_SETTINGS
+pub fn get_builtin_option(key: &str) -> String {
+ config::BUILTIN_SETTINGS
.read()
.unwrap()
.get(key)
@@ -781,6 +781,7 @@ pub fn http_request(url: String, method: String, body: Option<String>, header: S
current_request.lock().unwrap().insert(url, res);
});
}
+
#[inline]
pub fn get_async_http_status(url: String) -> Option<String> {
match ASYNC_HTTP_STATUS.lock().unwrap().get(&url) {