Skip to content

Commit

Permalink
Merge pull request #9 from DanielPower/auto-detect-folder-linux
Browse files Browse the repository at this point in the history
Add folder detection for osu! linux (osu-winello)
  • Loading branch information
CaptSiro authored Sep 30, 2024
2 parents 4a525c9 + 982b6cc commit 7bc7b6c
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions src/main/router/dir-router.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { Router } from '../lib/route-pass/Router';
import { none, some } from '../lib/rust-like-utils-backend/Optional';
import { dialog } from 'electron';
import { Router } from "../lib/route-pass/Router";
import { none, some } from "../lib/rust-like-utils-backend/Optional";
import { dialog } from "electron";
import path from "path";



let waitList: ((dir: string) => void)[] = [];

Router.respond("dir::select", () => {
Expand All @@ -21,11 +19,18 @@ Router.respond("dir::select", () => {
});

Router.respond("dir::autoGetOsuSongsDir", () => {
if (process.env.LOCALAPPDATA === undefined) {
return none();
if (process.platform === "win32") {
if (process.env.LOCALAPPDATA === undefined) {
return none();
}
return some(path.join(process.env.LOCALAPPDATA, "osu!", "Songs"));
} else if (process.platform === "linux") {
if (process.env.XDG_DATA_HOME === undefined) {
return none();
}
return some(path.join(process.env.XDG_DATA_HOME, "osu-wine", "osu!", "Songs"));
}

return some(path.join(process.env.LOCALAPPDATA, "osu!", "Songs"));
return none();
});

Router.respond("dir::submit", (_evt, dir) => {
Expand All @@ -36,10 +41,8 @@ Router.respond("dir::submit", (_evt, dir) => {
waitList = [];
});



export function dirSubmit(): Promise<string> {
return new Promise(resolve => {
return new Promise((resolve) => {
waitList.push(resolve);
});
}
}

0 comments on commit 7bc7b6c

Please sign in to comment.