A photo manager for VRChat.
at main 31 lines 985 B view raw
1use std::process::Command; 2 3#[tauri::command] 4pub fn open_folder(url: &str) { 5 #[cfg(target_os = "windows")] 6 Command::new("explorer.exe").arg(format!("/select,{}", url)).spawn().unwrap(); 7 8 #[cfg(target_os = "linux")] 9 { 10 let path = url.replace("\\", "/"); 11 12 let mut dir_path: Vec<_> = path.split("/").collect(); 13 dir_path.pop(); 14 let dir_path = dir_path.join("/"); 15 16 let commands = vec![ 17 ( "nautilus", vec![ path.clone() ] ), 18 ( "nemo", vec![ path.clone() ] ), 19 ( "thunar", vec![ path.clone() ] ), 20 ( "caja", vec![ "--select".into(), path.clone() ] ), 21 ( "pcmanfm-qt", vec![ dir_path.clone() ] ), 22 ( "pcmanfm", vec![ dir_path.clone() ] ), 23 ( "dolphin", vec![ "--select".into(), path.clone() ] ), 24 ( "konqueror", vec![ "--select".into(), path.clone() ] ), 25 ( "xdg-open", vec![ dir_path.clone() ] ) 26 ]; 27 28 for command in commands{ 29 if Command::new(command.0).args(command.1).spawn().is_ok() { break; } } 30 } 31}