Skip to content

Commit

Permalink
Fix #217
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamVenner committed Mar 12, 2024
1 parent 4296848 commit 5135a43
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
10 changes: 10 additions & 0 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ ureq = { version = "2.9.4", features = ["native-tls"] }
regex = "1"
steamworks = { version = "0.10", features = ["serde"] }

[target.'cfg(target_os = "linux")'.dependencies]
fork = "0.1"

[features]
# this feature is used for production builds or when `devPath` points to the filesystem
# DO NOT REMOVE!!
Expand Down
30 changes: 28 additions & 2 deletions src-tauri/src/util/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,34 @@ pub fn open_file_location<P: AsRef<Path>>(path: P) {
#[cfg(target_os = "macos")]
return std::process::Command::new("open").arg("-R").arg(path.to_string()).spawn();

#[cfg(target_os = "linux")]
return std::process::Command::new("xdg-open").arg("--select").arg(path.to_string()).spawn();
#[cfg(target_os = "linux")] {
return if path.contains(",") {
// see https://gitlab.freedesktop.org/dbus/dbus/-/issues/76
let new_path = match std::fs::metadata(&path).unwrap().is_dir() {
true => path,
false => {
let mut path2 = PathBuf::from(path);
path2.pop();
path2.into_os_string().into_string().unwrap()
}
};
return std::process::Command::new("xdg-open").arg(&new_path).spawn();
} else {
if let Ok(fork::Fork::Child) = fork::daemon(false, false) {
return std::process::Command::new("dbus-send")
.args([
"--session",
"--dest=org.freedesktop.FileManager1",
"--type=method_call",
"/org/freedesktop/FileManager1",
"org.freedesktop.FileManager1.ShowItems",
format!("array:string:\"file://{path}\"").as_str(),
"string:\"\"",
])
.spawn();
}
};
}

#[cfg(not(any(target_os = "windows", target_os = "macos", target_os = "linux")))]
Err(std::io::Error::new(std::io::ErrorKind::Other, "Unsupported OS"))
Expand Down

0 comments on commit 5135a43

Please sign in to comment.