mirror of
https://github.com/rustdesk/rustdesk.git
synced 2024-11-23 19:49:05 +08:00
use autostart for --tray in linux because pkexec not work well when start it with --server
This commit is contained in:
parent
b14ae250b7
commit
87b32ad8c4
@ -8,4 +8,3 @@ Icon=rustdesk
|
||||
Terminal=false
|
||||
Type=Application
|
||||
StartupNotify=false
|
||||
Version=1.5
|
||||
|
@ -1,5 +1,5 @@
|
||||
[Desktop Entry]
|
||||
Version=1.5
|
||||
Version=1.2.0
|
||||
Name=RustDesk
|
||||
GenericName=Remote Desktop
|
||||
Comment=Remote Desktop
|
||||
|
@ -1071,17 +1071,17 @@ pub fn check_process(arg: &str, same_uid: bool) -> bool {
|
||||
.map(|x| x.user_id())
|
||||
.unwrap_or_default();
|
||||
for (_, p) in sys.processes().iter() {
|
||||
if p.pid().to_string() == std::process::id().to_string() {
|
||||
continue;
|
||||
}
|
||||
if same_uid && p.user_id() != my_uid {
|
||||
continue;
|
||||
}
|
||||
if p.cmd().is_empty() || p.cmd()[0] != app {
|
||||
if p.exe().to_string_lossy() != app {
|
||||
continue;
|
||||
}
|
||||
if arg.is_empty() {
|
||||
if p.cmd().len() == 1 {
|
||||
return true;
|
||||
}
|
||||
} else if p.cmd().len() > 1 && p.cmd()[1] == arg {
|
||||
let parg = if p.cmd().len() <= 1 { "" } else { &p.cmd()[1] };
|
||||
if arg == parg {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -41,6 +41,14 @@ pub fn core_main() -> Option<Vec<String>> {
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
#[cfg(any(target_os = "linux", target_os = "windows"))]
|
||||
if args.is_empty() {
|
||||
#[cfg(target_os = "linux")]
|
||||
hbb_common::allow_err!(crate::platform::check_autostart_config());
|
||||
if crate::check_process("--server", false) && !crate::check_process("--tray", true) {
|
||||
hbb_common::allow_err!(crate::run_me(vec!["--tray"]));
|
||||
}
|
||||
}
|
||||
#[cfg(not(debug_assertions))]
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
register_breakdown_handler(breakdown_callback);
|
||||
|
@ -11,6 +11,7 @@ use hbb_common::{
|
||||
};
|
||||
use std::{
|
||||
cell::RefCell,
|
||||
io::Write,
|
||||
path::{Path, PathBuf},
|
||||
process::{Child, Command},
|
||||
string::String,
|
||||
@ -1170,3 +1171,24 @@ fn check_if_stop_service() {
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
pub fn check_autostart_config() -> ResultType<()> {
|
||||
let home = std::env::var("HOME").unwrap_or_default();
|
||||
let path = format!("{home}/.config/autostart");
|
||||
let file = format!("{path}/rustdesk.desktop");
|
||||
std::fs::create_dir_all(&path).ok();
|
||||
if !Path::new(&file).exists() {
|
||||
// write text to the desktop file
|
||||
let mut file = std::fs::File::create(&file)?;
|
||||
file.write_all(
|
||||
"
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Exec=rustdesk --tray
|
||||
NoDisplay=false
|
||||
"
|
||||
.as_bytes(),
|
||||
)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user