mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-02-09 03:37:45 +03:00
fix: linux game tracking and closed button
This commit is contained in:
parent
ee4639e041
commit
7785d42021
1
.python-version
Normal file
1
.python-version
Normal file
@ -0,0 +1 @@
|
|||||||
|
3.9.20
|
@ -24,7 +24,11 @@ const closeGame = async (
|
|||||||
if (!game) return;
|
if (!game) return;
|
||||||
|
|
||||||
const gameProcess = processes.find((runningProcess) => {
|
const gameProcess = processes.find((runningProcess) => {
|
||||||
|
if (process.platform === "linux") {
|
||||||
|
return runningProcess.name === game.executablePath?.split("/").at(-1);
|
||||||
|
} else {
|
||||||
return runningProcess.exe === game.executablePath;
|
return runningProcess.exe === game.executablePath;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (gameProcess) {
|
if (gameProcess) {
|
||||||
|
@ -35,4 +35,5 @@ export interface LibtorrentPayload {
|
|||||||
export interface ProcessPayload {
|
export interface ProcessPayload {
|
||||||
exe: string;
|
exe: string;
|
||||||
pid: number;
|
pid: number;
|
||||||
|
name: string;
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,27 @@ export const watchProcesses = async () => {
|
|||||||
if (games.length === 0) return;
|
if (games.length === 0) return;
|
||||||
const processes = await PythonInstance.getProcessList();
|
const processes = await PythonInstance.getProcessList();
|
||||||
|
|
||||||
|
if (process.platform === "linux") {
|
||||||
|
const processSet = new Set(processes.map((process) => process.name));
|
||||||
|
|
||||||
|
for (const game of games) {
|
||||||
|
const executable = game.executablePath?.split("/").at(-1);
|
||||||
|
|
||||||
|
if (!executable) continue;
|
||||||
|
|
||||||
|
const gameProcess = processSet.has(executable);
|
||||||
|
|
||||||
|
if (gameProcess) {
|
||||||
|
if (gamesPlaytime.has(game.id)) {
|
||||||
|
onTickGame(game);
|
||||||
|
} else {
|
||||||
|
onOpenGame(game);
|
||||||
|
}
|
||||||
|
} else if (gamesPlaytime.has(game.id)) {
|
||||||
|
onCloseGame(game);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
const processSet = new Set(processes.map((process) => process.exe));
|
const processSet = new Set(processes.map((process) => process.exe));
|
||||||
|
|
||||||
for (const game of games) {
|
for (const game of games) {
|
||||||
@ -42,6 +63,7 @@ export const watchProcesses = async () => {
|
|||||||
onCloseGame(game);
|
onCloseGame(game);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
currentTick++;
|
currentTick++;
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ class Handler(BaseHTTPRequestHandler):
|
|||||||
self.end_headers()
|
self.end_headers()
|
||||||
return
|
return
|
||||||
|
|
||||||
process_list = [proc.info for proc in psutil.process_iter(['exe', 'pid', 'username'])]
|
process_list = [proc.info for proc in psutil.process_iter(['exe', 'pid', 'name'])]
|
||||||
|
|
||||||
self.send_response(200)
|
self.send_response(200)
|
||||||
self.send_header("Content-type", "application/json")
|
self.send_header("Content-type", "application/json")
|
||||||
|
Loading…
Reference in New Issue
Block a user