fix(linux): osu-winello detection
This commit is contained in:
1 parent
01628e8514
commit
417f54a94a
2 files changed
+42
-14
No files matched your search
@@ -6,7 +6,6 @@ use serde_json::Value;
|
|||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::process::Stdio;
|
|
||||||
use sysinfo::System;
|
use sysinfo::System;
|
||||||
use tauri::AppHandle;
|
use tauri::AppHandle;
|
||||||
use tauri::Emitter;
|
use tauri::Emitter;
|
||||||
@@ -23,8 +22,8 @@ use crate::presence;
|
|||||||
use crate::state::AppState;
|
use crate::state::AppState;
|
||||||
use crate::utils::{
|
use crate::utils::{
|
||||||
check_folder_completeness, encrypt_password, get_osu_config, get_osu_user_config,
|
check_folder_completeness, encrypt_password, get_osu_config, get_osu_user_config,
|
||||||
get_window_title_by_pid, is_net8_installed, is_osuwinello_available, is_wmctrl_available,
|
get_osuwinello_path, get_window_title_by_pid, is_net8_installed, is_osuwinello_available,
|
||||||
set_osu_config_vals, set_osu_user_config_vals,
|
is_wmctrl_available, set_osu_config_vals, set_osu_user_config_vals,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
@@ -291,7 +290,8 @@ pub async fn run_osu_updater(folder: String) -> Result<(), String> {
|
|||||||
|
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
{
|
{
|
||||||
Command::new("osu-wine")
|
let osu_wine_path = get_osuwinello_path().expect("osu-wine was not found");
|
||||||
|
Command::new(&osu_wine_path)
|
||||||
.arg("-repair")
|
.arg("-repair")
|
||||||
.spawn()
|
.spawn()
|
||||||
.map_err(|e| format!("Failed to spawn updater: {}", e))?
|
.map_err(|e| format!("Failed to spawn updater: {}", e))?
|
||||||
@@ -376,7 +376,8 @@ pub async fn run_osu(folder: String, patch: bool) -> Result<(), String> {
|
|||||||
|
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
{
|
{
|
||||||
Command::new("osu-wine")
|
let osu_wine_path = get_osuwinello_path().expect("osu-wine was not found");
|
||||||
|
Command::new(&osu_wine_path)
|
||||||
.arg("--devserver")
|
.arg("--devserver")
|
||||||
.arg("ez-pp.farm")
|
.arg("ez-pp.farm")
|
||||||
.spawn()
|
.spawn()
|
||||||
@@ -425,7 +426,10 @@ pub async fn run_osu(folder: String, patch: bool) -> Result<(), String> {
|
|||||||
}
|
}
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
{
|
{
|
||||||
let _ = Command::new("osu-wine")
|
use crate::utils::get_osuwinello_path;
|
||||||
|
|
||||||
|
let osu_wine_path = get_osuwinello_path().expect("osu-wine was not found");
|
||||||
|
let _ = Command::new(&osu_wine_path)
|
||||||
.arg("--wine")
|
.arg("--wine")
|
||||||
.arg(&patcher_exe_path)
|
.arg(&patcher_exe_path)
|
||||||
.spawn()
|
.spawn()
|
||||||
|
|||||||
+32
-8
@@ -1,5 +1,5 @@
|
|||||||
use std::fs;
|
use std::fs;
|
||||||
use std::path::Path;
|
use std::path::{Path, PathBuf};
|
||||||
use sysinfo::Pid;
|
use sysinfo::Pid;
|
||||||
|
|
||||||
pub fn check_folder_completeness<P: AsRef<Path>>(folder_path: P, required_files: &[&str]) -> f32 {
|
pub fn check_folder_completeness<P: AsRef<Path>>(folder_path: P, required_files: &[&str]) -> f32 {
|
||||||
@@ -178,15 +178,39 @@ pub fn get_osu_config<P: AsRef<Path>>(
|
|||||||
return Some(config_map);
|
return Some(config_map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(windows))]
|
||||||
|
pub fn get_osuwinello_path() -> Option<PathBuf> {
|
||||||
|
let mut search_paths =
|
||||||
|
std::env::split_paths(&std::env::var_os("PATH").unwrap_or_default()).collect::<Vec<_>>();
|
||||||
|
|
||||||
|
for path in ["/usr/local/bin", "/usr/bin", "/bin"] {
|
||||||
|
let path = PathBuf::from(path);
|
||||||
|
if !search_paths.contains(&path) {
|
||||||
|
search_paths.push(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(home) = std::env::var_os("HOME") {
|
||||||
|
let path = Path::new(&home).join(".local/bin");
|
||||||
|
if !search_paths.contains(&path) {
|
||||||
|
search_paths.push(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
search_paths
|
||||||
|
.into_iter()
|
||||||
|
.map(|path| path.join("osu-wine"))
|
||||||
|
.find(|path| path.is_file())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(windows)]
|
||||||
|
pub fn get_osuwinello_path() -> Option<PathBuf> {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
pub fn is_osuwinello_available() -> bool {
|
pub fn is_osuwinello_available() -> bool {
|
||||||
use std::process::Command;
|
get_osuwinello_path().is_some()
|
||||||
Command::new("osu-wine")
|
|
||||||
.arg("--info")
|
|
||||||
.stdout(std::process::Stdio::null())
|
|
||||||
.stderr(std::process::Stdio::null())
|
|
||||||
.status()
|
|
||||||
.is_ok()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
|
|||||||
Reference in new issue
Block a user