use autostart for --tray in linux because pkexec not work well when start it with --server

This commit is contained in:
rustdesk
2023-06-10 01:55:32 +08:00
parent b14ae250b7
commit 87b32ad8c4
5 changed files with 37 additions and 8 deletions

View File

@@ -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(())
}