chore: try to fix service not started on linux

This commit is contained in:
huzibaca
2024-10-18 22:30:29 +08:00
parent 770f031b8b
commit ee78b7898b
12 changed files with 396 additions and 54 deletions

View File

@@ -105,6 +105,26 @@ pub fn open_file(app: tauri::AppHandle, path: PathBuf) -> Result<()> {
Ok(())
}
#[cfg(target_os = "linux")]
pub fn linux_elevator() -> String {
use std::process::Command;
match Command::new("which").arg("sudo").output() {
Ok(output) => {
if !output.stdout.is_empty() {
// Convert the output to a string slice
if let Ok(path) = std::str::from_utf8(&output.stdout) {
path.trim().to_string()
} else {
"sudo".to_string()
}
} else {
"sudo".to_string()
}
}
Err(_) => "sudo".to_string(),
}
}
#[macro_export]
macro_rules! error {
($result: expr) => {