mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
test vcpkg new in android
This commit is contained in:
@@ -326,17 +326,20 @@ fn set_x11_env(desktop: &Desktop) {
|
||||
#[inline]
|
||||
fn stop_rustdesk_servers() {
|
||||
let _ = run_cmds(&format!(
|
||||
r##"ps -ef | grep -E 'rustdesk +--server' | awk '{{printf("kill -9 %d\n", $2)}}' | bash"##,
|
||||
r##"ps -ef | grep -E '{} +--server' | awk '{{printf("kill -9 %d\n", $2)}}' | bash"##,
|
||||
crate::get_app_name().to_lowercase(),
|
||||
));
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn stop_subprocess() {
|
||||
let _ = run_cmds(&format!(
|
||||
r##"ps -ef | grep '/etc/rustdesk/xorg.conf' | grep -v grep | awk '{{printf("kill -9 %d\n", $2)}}' | bash"##,
|
||||
r##"ps -ef | grep '/etc/{}/xorg.conf' | grep -v grep | awk '{{printf("kill -9 %d\n", $2)}}' | bash"##,
|
||||
crate::get_app_name().to_lowercase(),
|
||||
));
|
||||
let _ = run_cmds(&format!(
|
||||
r##"ps -ef | grep -E 'rustdesk +--cm-no-ui' | grep -v grep | awk '{{printf("kill -9 %d\n", $2)}}' | bash"##,
|
||||
r##"ps -ef | grep -E '{} +--cm-no-ui' | grep -v grep | awk '{{printf("kill -9 %d\n", $2)}}' | bash"##,
|
||||
crate::get_app_name().to_lowercase(),
|
||||
));
|
||||
}
|
||||
|
||||
@@ -771,10 +774,13 @@ pub fn exec_privileged(args: &[&str]) -> ResultType<Child> {
|
||||
}
|
||||
|
||||
pub fn check_super_user_permission() -> ResultType<bool> {
|
||||
let file = "/usr/share/rustdesk/files/polkit";
|
||||
let file = format!(
|
||||
"/usr/share/{}/files/polkit",
|
||||
crate::get_app_name().to_lowercase()
|
||||
);
|
||||
let arg;
|
||||
if Path::new(file).is_file() {
|
||||
arg = file;
|
||||
if Path::new(&file).is_file() {
|
||||
arg = &file;
|
||||
} else {
|
||||
arg = "echo";
|
||||
}
|
||||
@@ -988,7 +994,6 @@ mod desktop {
|
||||
const IBUS_DAEMON: &str = "ibus-daemon";
|
||||
const PLASMA_KDED: &str = "kded[0-9]+";
|
||||
const GNOME_GOA_DAEMON: &str = "goa-daemon";
|
||||
const RUSTDESK_TRAY: &str = "rustdesk +--tray";
|
||||
|
||||
#[derive(Debug, Clone, Default)]
|
||||
pub struct Desktop {
|
||||
@@ -1020,14 +1025,10 @@ mod desktop {
|
||||
}
|
||||
|
||||
fn get_display_xauth_xwayland(&mut self) {
|
||||
let tray = format!("{} +--tray", crate::get_app_name().to_lowercase());
|
||||
for _ in 0..5 {
|
||||
let display_proc = vec![
|
||||
XWAYLAND,
|
||||
IBUS_DAEMON,
|
||||
GNOME_GOA_DAEMON,
|
||||
PLASMA_KDED,
|
||||
RUSTDESK_TRAY,
|
||||
];
|
||||
let display_proc =
|
||||
vec![XWAYLAND, IBUS_DAEMON, GNOME_GOA_DAEMON, PLASMA_KDED, &tray];
|
||||
for proc in display_proc {
|
||||
self.display = get_env("DISPLAY", &self.uid, proc);
|
||||
self.xauth = get_env("XAUTHORITY", &self.uid, proc);
|
||||
@@ -1124,6 +1125,7 @@ mod desktop {
|
||||
|
||||
fn get_xauth_x11(&mut self) {
|
||||
// try by direct access to window manager process by name
|
||||
let tray = format!("{} +--tray", crate::get_app_name().to_lowercase());
|
||||
for _ in 0..10 {
|
||||
let display_proc = vec![
|
||||
XWAYLAND,
|
||||
@@ -1132,7 +1134,7 @@ mod desktop {
|
||||
PLASMA_KDED,
|
||||
XFCE4_PANEL,
|
||||
SDDM_GREETER,
|
||||
RUSTDESK_TRAY,
|
||||
&tray,
|
||||
];
|
||||
for proc in display_proc {
|
||||
self.xauth = get_env("XAUTHORITY", &self.uid, proc);
|
||||
@@ -1217,8 +1219,11 @@ mod desktop {
|
||||
|
||||
fn set_is_subprocess(&mut self) {
|
||||
self.is_rustdesk_subprocess = false;
|
||||
let cmd = "ps -ef | grep 'rustdesk/xorg.conf' | grep -v grep | wc -l";
|
||||
if let Ok(res) = run_cmds(cmd) {
|
||||
let cmd = format!(
|
||||
"ps -ef | grep '{}/xorg.conf' | grep -v grep | wc -l",
|
||||
crate::get_app_name().to_lowercase()
|
||||
);
|
||||
if let Ok(res) = run_cmds(&cmd) {
|
||||
if res.trim() != "0" {
|
||||
self.is_rustdesk_subprocess = true;
|
||||
}
|
||||
@@ -1350,7 +1355,9 @@ fn switch_service(stop: bool) -> String {
|
||||
let home = std::env::var("HOME").unwrap_or_default();
|
||||
Config::set_option("stop-service".into(), if stop { "Y" } else { "" }.into());
|
||||
if home != "/root" && !Config::get().is_empty() {
|
||||
format!("cp -f {home}/.config/rustdesk/RustDesk.toml /root/.config/rustdesk/; cp -f {home}/.config/rustdesk/RustDesk2.toml /root/.config/rustdesk/;")
|
||||
let app_name0 = crate::get_app_name().to_lowercase();
|
||||
let app_name = crate::get_app_name();
|
||||
format!("cp -f {home}/.config/{app_name}/{app_name0}.toml /root/.config/{app_name}/; cp -f {home}/.config/{app_name}/{app_name0}2.toml /root/.config/{app_name}/;")
|
||||
} else {
|
||||
"".to_owned()
|
||||
}
|
||||
@@ -1362,8 +1369,9 @@ pub fn uninstall_service(show_new_window: bool, _: bool) -> bool {
|
||||
}
|
||||
log::info!("Uninstalling service...");
|
||||
let cp = switch_service(true);
|
||||
let app_name = crate::get_app_name().to_lowercase();
|
||||
if !run_cmds_pkexec(&format!(
|
||||
"systemctl disable rustdesk; systemctl stop rustdesk; {cp}"
|
||||
"systemctl disable {app_name}; systemctl stop {app_name}; {cp}"
|
||||
)) {
|
||||
Config::set_option("stop-service".into(), "".into());
|
||||
return true;
|
||||
@@ -1381,8 +1389,9 @@ pub fn install_service() -> bool {
|
||||
}
|
||||
log::info!("Installing service...");
|
||||
let cp = switch_service(false);
|
||||
let app_name = crate::get_app_name().to_lowercase();
|
||||
if !run_cmds_pkexec(&format!(
|
||||
"{cp} systemctl enable rustdesk; systemctl start rustdesk;"
|
||||
"{cp} systemctl enable {app_name}; systemctl start {app_name};"
|
||||
)) {
|
||||
Config::set_option("stop-service".into(), "Y".into());
|
||||
return true;
|
||||
@@ -1393,27 +1402,31 @@ pub fn install_service() -> bool {
|
||||
|
||||
fn check_if_stop_service() {
|
||||
if Config::get_option("stop-service".into()) == "Y" {
|
||||
let app_name = crate::get_app_name().to_lowercase();
|
||||
allow_err!(run_cmds(
|
||||
"systemctl disable rustdesk; systemctl stop rustdesk"
|
||||
"systemctl disable {app_name}; systemctl stop {app_name}"
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
pub fn check_autostart_config() -> ResultType<()> {
|
||||
let home = std::env::var("HOME").unwrap_or_default();
|
||||
let app_name = crate::get_app_name().to_lowercase();
|
||||
let path = format!("{home}/.config/autostart");
|
||||
let file = format!("{path}/rustdesk.desktop");
|
||||
let file = format!("{path}/{app_name}.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(
|
||||
"
|
||||
format!(
|
||||
"
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Exec=rustdesk --tray
|
||||
Exec={app_name} --tray
|
||||
NoDisplay=false
|
||||
"
|
||||
)
|
||||
.as_bytes(),
|
||||
)?;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user