feat: add linux support with osu-winello
This commit is contained in:
parent
5aec2d8245
commit
1a563e64d5
2
src-tauri/Cargo.lock
generated
2
src-tauri/Cargo.lock
generated
@ -1094,7 +1094,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ezpplauncher"
|
||||
version = "3.0.0-beta.3"
|
||||
version = "3.0.0-beta.4"
|
||||
dependencies = [
|
||||
"discord-rich-presence",
|
||||
"hardware-id",
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ezpplauncher"
|
||||
version = "3.0.0-beta.3"
|
||||
version = "3.0.0-beta.4"
|
||||
description = "EZPPLauncher redefined."
|
||||
authors = ["HorizonCode"]
|
||||
edition = "2024"
|
||||
|
@ -14,7 +14,7 @@ use tokio::time::{Duration, sleep};
|
||||
use crate::presence;
|
||||
use crate::utils::{
|
||||
check_folder_completeness, get_osu_config, get_osu_user_config, get_window_title_by_pid,
|
||||
set_osu_config_vals, set_osu_user_config_vals,
|
||||
set_osu_config_vals, set_osu_user_config_vals, is_wmctrl_available, is_osuwinello_available
|
||||
};
|
||||
|
||||
#[tauri::command]
|
||||
@ -282,8 +282,6 @@ pub fn set_osu_config_values(
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn run_osu_updater(folder: String) -> Result<(), String> {
|
||||
let osu_exe_path = PathBuf::from(&folder).join("osu!.exe");
|
||||
|
||||
#[cfg(windows)]
|
||||
const DETACHED_PROCESS: u32 = 0x00000008;
|
||||
#[cfg(windows)]
|
||||
@ -292,6 +290,7 @@ pub async fn run_osu_updater(folder: String) -> Result<(), String> {
|
||||
let mut updater_process = {
|
||||
#[cfg(windows)]
|
||||
{
|
||||
let osu_exe_path = PathBuf::from(&folder).join("osu!.exe");
|
||||
Command::new(&osu_exe_path)
|
||||
.arg("-repair")
|
||||
.creation_flags(DETACHED_PROCESS | CREATE_NEW_PROCESS_GROUP)
|
||||
@ -301,7 +300,7 @@ pub async fn run_osu_updater(folder: String) -> Result<(), String> {
|
||||
|
||||
#[cfg(not(windows))]
|
||||
{
|
||||
Command::new(&osu_exe_path)
|
||||
Command::new("osu-wine")
|
||||
.arg("-repair")
|
||||
.spawn()
|
||||
.map_err(|e| format!("Failed to spawn updater: {}", e))?
|
||||
@ -372,8 +371,6 @@ pub async fn run_osu(folder: String, patch: bool) -> Result<(), String> {
|
||||
/* #[cfg(windows)]
|
||||
use std::os::windows::process::CommandExt; */
|
||||
|
||||
let osu_exe_path = PathBuf::from(&folder).join("osu!.exe");
|
||||
|
||||
#[cfg(windows)]
|
||||
const DETACHED_PROCESS: u32 = 0x00000008;
|
||||
#[cfg(windows)]
|
||||
@ -382,6 +379,7 @@ pub async fn run_osu(folder: String, patch: bool) -> Result<(), String> {
|
||||
let mut game_process = {
|
||||
#[cfg(windows)]
|
||||
{
|
||||
let osu_exe_path = PathBuf::from(&folder).join("osu!.exe");
|
||||
Command::new(&osu_exe_path)
|
||||
.arg("-devserver")
|
||||
.arg("ez-pp.farm")
|
||||
@ -392,8 +390,8 @@ pub async fn run_osu(folder: String, patch: bool) -> Result<(), String> {
|
||||
|
||||
#[cfg(not(windows))]
|
||||
{
|
||||
Command::new(&osu_exe_path)
|
||||
.arg("-devserver")
|
||||
Command::new("osu-wine")
|
||||
.arg("--devserver")
|
||||
.arg("ez-pp.farm")
|
||||
.spawn()
|
||||
.map_err(|e| format!("Failed to spawn updater: {}", e))?
|
||||
@ -416,13 +414,6 @@ pub async fn run_osu(folder: String, patch: bool) -> Result<(), String> {
|
||||
.spawn()
|
||||
.map_err(|e| format!("Failed to run patcher: {e}"))?;
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
{
|
||||
let _ = Command::new(&patcher_exe_path)
|
||||
.spawn()
|
||||
.map_err(|e| format!("Failed to run patcher: {e}"))?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -713,3 +704,13 @@ pub async fn presence_update_user(user: PresenceUser) {
|
||||
pub async fn presence_is_connected() -> bool {
|
||||
presence::has_presence().await
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn has_wmctrl() -> bool {
|
||||
is_wmctrl_available()
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn has_osuwinello() -> bool {
|
||||
is_osuwinello_available()
|
||||
}
|
@ -10,7 +10,7 @@ use crate::commands::{
|
||||
get_osu_release_stream, get_osu_skin, get_osu_version, get_platform, get_skins_count,
|
||||
is_osu_running, open_url_in_browser, presence_connect, presence_disconnect,
|
||||
presence_is_connected, presence_update_status, presence_update_user, replace_ui_files, run_osu,
|
||||
run_osu_updater, set_osu_config_values, set_osu_user_config_values, valid_osu_folder,
|
||||
run_osu_updater, set_osu_config_values, set_osu_user_config_values, valid_osu_folder, has_osuwinello, has_wmctrl
|
||||
};
|
||||
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
@ -60,7 +60,9 @@ pub fn run() {
|
||||
presence_disconnect,
|
||||
presence_update_status,
|
||||
presence_update_user,
|
||||
presence_is_connected
|
||||
presence_is_connected,
|
||||
has_osuwinello,
|
||||
has_wmctrl
|
||||
])
|
||||
.plugin(tauri_plugin_fs::init())
|
||||
.plugin(tauri_plugin_dialog::init())
|
||||
|
@ -1,5 +1,6 @@
|
||||
use std::fs;
|
||||
use std::path::Path;
|
||||
use std::process::Command;
|
||||
use sysinfo::Pid;
|
||||
|
||||
pub fn check_folder_completeness<P: AsRef<Path>>(folder_path: P, required_files: &[&str]) -> f32 {
|
||||
@ -177,8 +178,68 @@ pub fn get_osu_config<P: AsRef<Path>>(
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
pub fn get_window_title_by_pid(_pid: Pid) -> String {
|
||||
"".to_string()
|
||||
pub fn is_osuwinello_available() -> bool {
|
||||
Command::new("osu-wine")
|
||||
.arg("--info") // A lightweight operation like getting the version is ideal.
|
||||
.stdout(std::process::Stdio::null()) // Suppress stdout
|
||||
.stderr(std::process::Stdio::null()) // Suppress stderr
|
||||
.status() // Execute the command and get its status
|
||||
.is_ok() // is_ok() will be true if the command was found and ran
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
pub fn is_osuwinello_available() -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
pub fn is_wmctrl_available() -> bool {
|
||||
Command::new("wmctrl")
|
||||
.arg("-V") // A lightweight operation like getting the version is ideal.
|
||||
.stdout(std::process::Stdio::null()) // Suppress stdout
|
||||
.stderr(std::process::Stdio::null()) // Suppress stderr
|
||||
.status() // Execute the command and get its status
|
||||
.is_ok() // is_ok() will be true if the command was found and ran
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
pub fn is_wmctrl_available() -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
pub fn get_window_title_by_pid(target_pid: Pid) -> String {
|
||||
let find_title = || -> Option<String> {
|
||||
// 1. Execute `wmctrl -lp`
|
||||
let output = Command::new("wmctrl").arg("-lp").output().ok()?;
|
||||
|
||||
if !output.status.success() {
|
||||
return None; // wmctrl command failed (e.g., not on X11)
|
||||
}
|
||||
|
||||
let output_str = String::from_utf8(output.stdout).ok()?;
|
||||
|
||||
// 2. Parse the output line by line
|
||||
for line in output_str.lines() {
|
||||
let parts: Vec<&str> = line.split_whitespace().collect();
|
||||
if parts.len() < 4 {
|
||||
continue;
|
||||
}
|
||||
|
||||
// The PID is typically the 3rd column (index 2)
|
||||
if let Ok(pid) = parts[2].parse::<u32>() {
|
||||
if pid == target_pid.as_u32() {
|
||||
// 3. Extract the title and return it as Some(title)
|
||||
let title = parts[4..].join(" ");
|
||||
return Some(title);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
None
|
||||
};
|
||||
|
||||
find_title().unwrap_or_default()
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
|
@ -6,6 +6,8 @@ import type { Release } from './types';
|
||||
|
||||
export const currentView = writable<Component>(Loading);
|
||||
|
||||
export const platform = writable<string>("");
|
||||
|
||||
export const launcherVersion = writable<string>('');
|
||||
export const newVersion = writable<Release | undefined>(undefined);
|
||||
|
||||
|
@ -116,3 +116,7 @@ export const exit = async () => await invoke('exit');
|
||||
export const getPlatform = async () => await invoke<string>('get_platform');
|
||||
export const isOsuCorrupted = async (folder: string) =>
|
||||
await invoke<boolean>('check_for_corruption', { folder });
|
||||
export const hasWMCTRL = async () =>
|
||||
await invoke<boolean>('has_wmctrl');
|
||||
export const hasOsuWinello = async () =>
|
||||
await invoke<boolean>('has_osuwinello');
|
@ -14,6 +14,7 @@
|
||||
newVersion,
|
||||
osuBuild,
|
||||
osuStream,
|
||||
platform,
|
||||
presenceLoading,
|
||||
serverConnectionFails,
|
||||
serverPing,
|
||||
@ -87,6 +88,8 @@
|
||||
getSkin,
|
||||
getSkinsCount,
|
||||
getVersion,
|
||||
hasOsuWinello,
|
||||
hasWMCTRL,
|
||||
isOsuCorrupted,
|
||||
isOsuRunning,
|
||||
isValidOsuFolder,
|
||||
@ -184,6 +187,23 @@
|
||||
return;
|
||||
}
|
||||
|
||||
if($platform === "linux"){
|
||||
if(!(await hasWMCTRL())){
|
||||
toast.error('Hmmm...', {
|
||||
description: 'wmctrl seems to be missing, please install via AUR.',
|
||||
});
|
||||
launching.set(false);
|
||||
return;
|
||||
}
|
||||
if(!(await hasOsuWinello())){
|
||||
toast.error('Hmmm...', {
|
||||
description: 'osu-winello seems to be missing, please install it.',
|
||||
});
|
||||
launching.set(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
launchInfo = 'Looking for EZPPLauncher File updates...';
|
||||
const updateResult = await getEZPPLauncherUpdateFiles(osuPath);
|
||||
@ -1028,11 +1048,12 @@
|
||||
>
|
||||
<div class="flex flex-col">
|
||||
<Label class="text-sm" for="setting-custom-cursor">Patching</Label>
|
||||
<div class="text-muted-foreground text-xs">Shows misses in Relax and Autopilot</div>
|
||||
<div class="text-muted-foreground text-xs">Shows misses in Relax and Autopilot {#if $platform !== "windows"}<span class="text-red-500 bg-red-800/20 border border-red-600/20 p-0.5 mx-1 px-2 rounded-lg">currently only on windows!</span> {/if}</div>
|
||||
</div>
|
||||
<Checkbox
|
||||
id="setting-custom-cursor"
|
||||
checked={$patch}
|
||||
checked={$platform === "windows" ? $patch : false}
|
||||
disabled={$platform !== "windows"}
|
||||
onCheckedChange={async (e) => {
|
||||
patch.set(e);
|
||||
$userSettings.save();
|
||||
|
@ -9,6 +9,7 @@
|
||||
discordPresence,
|
||||
firstStartup,
|
||||
launcherVersion,
|
||||
platform,
|
||||
presenceLoading,
|
||||
setupValues,
|
||||
} from '@/global';
|
||||
@ -90,7 +91,8 @@
|
||||
disableReload();
|
||||
setupValues();
|
||||
launcherVersion.set(await getLauncherVersion());
|
||||
if ((await getPlatform()) !== 'windows') unsupported_platform = true;
|
||||
platform.set(await getPlatform());
|
||||
if ($platform !== "windows" && $platform !== "linux") unsupported_platform = true;
|
||||
const isFirstStartup = await $userSettings.init();
|
||||
$userAuth.init();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user