mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-03-09 15:40:26 +00:00
feat: get process list from rpc
This commit is contained in:
parent
0c1a75eedd
commit
75c8f69e81
10 changed files with 57 additions and 49 deletions
|
@ -1,11 +1,9 @@
|
|||
import path from "node:path";
|
||||
|
||||
import { IsNull, Not } from "typeorm";
|
||||
import { gameRepository } from "@main/repository";
|
||||
import { getProcesses } from "@main/helpers";
|
||||
import { WindowManager } from "./window-manager";
|
||||
import { createGame, updateGamePlaytime } from "./library-sync";
|
||||
import { GameRunning } from "@types";
|
||||
import { RPCManager } from "./download";
|
||||
|
||||
export const gamesPlaytime = new Map<
|
||||
number,
|
||||
|
@ -22,22 +20,13 @@ export const watchProcesses = async () => {
|
|||
|
||||
if (games.length === 0) return;
|
||||
|
||||
const processes = await getProcesses();
|
||||
const processes = (await RPCManager.getProccessList()) || [];
|
||||
|
||||
for (const game of games) {
|
||||
const executablePath = game.executablePath!;
|
||||
const basename = path.win32.basename(executablePath);
|
||||
const basenameWithoutExtension = path.win32.basename(
|
||||
executablePath,
|
||||
path.extname(executablePath)
|
||||
);
|
||||
|
||||
const gameProcess = processes.find((runningProcess) => {
|
||||
if (process.platform === "win32") {
|
||||
return runningProcess.name === basename;
|
||||
}
|
||||
|
||||
return [basename, basenameWithoutExtension].includes(runningProcess.name);
|
||||
return executablePath == runningProcess;
|
||||
});
|
||||
|
||||
if (gameProcess) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue