fix(linux): osu-winello detection

This commit is contained in:
2026-09-07 23:46:23 +02:00
parent 01628e8514
commit 417f54a94a
2 changed files with 42 additions and 14 deletions
+10 -6
View File
@@ -6,7 +6,6 @@ use serde_json::Value;
use std::collections::HashSet;
use std::io::Read;
use std::path::PathBuf;
use std::process::Stdio;
use sysinfo::System;
use tauri::AppHandle;
use tauri::Emitter;
@@ -23,8 +22,8 @@ use crate::presence;
use crate::state::AppState;
use crate::utils::{
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,
set_osu_config_vals, set_osu_user_config_vals,
get_osuwinello_path, get_window_title_by_pid, is_net8_installed, is_osuwinello_available,
is_wmctrl_available, set_osu_config_vals, set_osu_user_config_vals,
};
#[tauri::command]
@@ -291,7 +290,8 @@ pub async fn run_osu_updater(folder: String) -> Result<(), String> {
#[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")
.spawn()
.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))]
{
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("ez-pp.farm")
.spawn()
@@ -425,7 +426,10 @@ pub async fn run_osu(folder: String, patch: bool) -> Result<(), String> {
}
#[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(&patcher_exe_path)
.spawn()
+32 -8
View File
@@ -1,5 +1,5 @@
use std::fs;
use std::path::Path;
use std::path::{Path, PathBuf};
use sysinfo::Pid;
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);
}
#[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))]
pub fn is_osuwinello_available() -> bool {
use std::process::Command;
Command::new("osu-wine")
.arg("--info")
.stdout(std::process::Stdio::null())
.stderr(std::process::Stdio::null())
.status()
.is_ok()
get_osuwinello_path().is_some()
}
#[cfg(windows)]