mirror of
https://github.com/Zagrios/bs-manager.git
synced 2026-07-03 14:08:25 +02:00
Get running processes independent of platform
This commit is contained in:
Generated
+36
-9
@@ -10,7 +10,6 @@
|
||||
"dependencies": {
|
||||
"@node-steam/vdf": "^2.2.0",
|
||||
"@tippyjs/react": "^4.2.6",
|
||||
"@types/color": "^3.0.3",
|
||||
"archiver": "^5.3.1",
|
||||
"color": "^4.2.3",
|
||||
"dateformat": "^5.0.3",
|
||||
@@ -28,6 +27,7 @@
|
||||
"md5-file": "^5.0.0",
|
||||
"node-fetch": "^2.6.7",
|
||||
"node-stream-zip": "^1.15.0",
|
||||
"ps-list": "^8.1.1",
|
||||
"react": "^18.2.0",
|
||||
"react-colorful": "^5.6.1",
|
||||
"react-dom": "^18.2.0",
|
||||
@@ -54,6 +54,7 @@
|
||||
"@testing-library/jest-dom": "^5.16.5",
|
||||
"@testing-library/react": "^13.3.0",
|
||||
"@types/archiver": "^5.3.1",
|
||||
"@types/color": "^3.0.3",
|
||||
"@types/dateformat": "^5.0.0",
|
||||
"@types/jest": "^27.5.2",
|
||||
"@types/node": "17.0.23",
|
||||
@@ -2281,6 +2282,7 @@
|
||||
"version": "3.0.3",
|
||||
"resolved": "https://registry.npmjs.org/@types/color/-/color-3.0.3.tgz",
|
||||
"integrity": "sha512-X//qzJ3d3Zj82J9sC/C18ZY5f43utPbAJ6PhYt/M7uG6etcF6MRpKdN880KBy43B0BMzSfeT96MzrsNjFI3GbA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@types/color-convert": "*"
|
||||
}
|
||||
@@ -2289,6 +2291,7 @@
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/color-convert/-/color-convert-2.0.0.tgz",
|
||||
"integrity": "sha512-m7GG7IKKGuJUXvkZ1qqG3ChccdIM/qBBo913z+Xft0nKCX4hAU/IxKwZBU4cpRZ7GS5kV4vOblUkILtSShCPXQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@types/color-name": "*"
|
||||
}
|
||||
@@ -2296,7 +2299,8 @@
|
||||
"node_modules/@types/color-name": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/color-name/-/color-name-1.1.1.tgz",
|
||||
"integrity": "sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ=="
|
||||
"integrity": "sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@types/connect": {
|
||||
"version": "3.4.35",
|
||||
@@ -4655,9 +4659,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/caniuse-lite": {
|
||||
"version": "1.0.30001431",
|
||||
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001431.tgz",
|
||||
"integrity": "sha512-zBUoFU0ZcxpvSt9IU66dXVT/3ctO1cy4y9cscs1szkPlcWb6pasYM144GqrUygUbT+k7cmUCW61cvskjcv0enQ==",
|
||||
"version": "1.0.30001508",
|
||||
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001508.tgz",
|
||||
"integrity": "sha512-sdQZOJdmt3GJs1UMNpCCCyeuS2IEGLXnHyAo9yIO5JJDjbjoVRij4M1qep6P6gFpptD1PqIYgzM+gwJbOi92mw==",
|
||||
"dev": true,
|
||||
"funding": [
|
||||
{
|
||||
@@ -4667,6 +4671,10 @@
|
||||
{
|
||||
"type": "tidelift",
|
||||
"url": "https://tidelift.com/funding/github/npm/caniuse-lite"
|
||||
},
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ai"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -14845,6 +14853,17 @@
|
||||
"node": ">= 0.10"
|
||||
}
|
||||
},
|
||||
"node_modules/ps-list": {
|
||||
"version": "8.1.1",
|
||||
"resolved": "https://registry.npmjs.org/ps-list/-/ps-list-8.1.1.tgz",
|
||||
"integrity": "sha512-OPS9kEJYVmiO48u/B9qneqhkMvgCxT+Tm28VCEJpheTpl8cJ0ffZRRNgS5mrQRTrX5yRTpaJ+hRDeefXYmmorQ==",
|
||||
"engines": {
|
||||
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/ps-scrollbar-tailwind": {
|
||||
"version": "0.0.1",
|
||||
"resolved": "https://registry.npmjs.org/ps-scrollbar-tailwind/-/ps-scrollbar-tailwind-0.0.1.tgz",
|
||||
@@ -20455,6 +20474,7 @@
|
||||
"version": "3.0.3",
|
||||
"resolved": "https://registry.npmjs.org/@types/color/-/color-3.0.3.tgz",
|
||||
"integrity": "sha512-X//qzJ3d3Zj82J9sC/C18ZY5f43utPbAJ6PhYt/M7uG6etcF6MRpKdN880KBy43B0BMzSfeT96MzrsNjFI3GbA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/color-convert": "*"
|
||||
}
|
||||
@@ -20463,6 +20483,7 @@
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/color-convert/-/color-convert-2.0.0.tgz",
|
||||
"integrity": "sha512-m7GG7IKKGuJUXvkZ1qqG3ChccdIM/qBBo913z+Xft0nKCX4hAU/IxKwZBU4cpRZ7GS5kV4vOblUkILtSShCPXQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/color-name": "*"
|
||||
}
|
||||
@@ -20470,7 +20491,8 @@
|
||||
"@types/color-name": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/color-name/-/color-name-1.1.1.tgz",
|
||||
"integrity": "sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ=="
|
||||
"integrity": "sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/connect": {
|
||||
"version": "3.4.35",
|
||||
@@ -22390,9 +22412,9 @@
|
||||
}
|
||||
},
|
||||
"caniuse-lite": {
|
||||
"version": "1.0.30001431",
|
||||
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001431.tgz",
|
||||
"integrity": "sha512-zBUoFU0ZcxpvSt9IU66dXVT/3ctO1cy4y9cscs1szkPlcWb6pasYM144GqrUygUbT+k7cmUCW61cvskjcv0enQ==",
|
||||
"version": "1.0.30001508",
|
||||
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001508.tgz",
|
||||
"integrity": "sha512-sdQZOJdmt3GJs1UMNpCCCyeuS2IEGLXnHyAo9yIO5JJDjbjoVRij4M1qep6P6gFpptD1PqIYgzM+gwJbOi92mw==",
|
||||
"dev": true
|
||||
},
|
||||
"chalk": {
|
||||
@@ -29968,6 +29990,11 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"ps-list": {
|
||||
"version": "8.1.1",
|
||||
"resolved": "https://registry.npmjs.org/ps-list/-/ps-list-8.1.1.tgz",
|
||||
"integrity": "sha512-OPS9kEJYVmiO48u/B9qneqhkMvgCxT+Tm28VCEJpheTpl8cJ0ffZRRNgS5mrQRTrX5yRTpaJ+hRDeefXYmmorQ=="
|
||||
},
|
||||
"ps-scrollbar-tailwind": {
|
||||
"version": "0.0.1",
|
||||
"resolved": "https://registry.npmjs.org/ps-scrollbar-tailwind/-/ps-scrollbar-tailwind-0.0.1.tgz",
|
||||
|
||||
@@ -248,6 +248,7 @@
|
||||
"md5-file": "^5.0.0",
|
||||
"node-fetch": "^2.6.7",
|
||||
"node-stream-zip": "^1.15.0",
|
||||
"ps-list": "^8.1.1",
|
||||
"react": "^18.2.0",
|
||||
"react-colorful": "^5.6.1",
|
||||
"react-dom": "^18.2.0",
|
||||
|
||||
@@ -55,8 +55,8 @@ export class BSLauncherService{
|
||||
return rename(steamVrFolder + ".bak", steamVrFolder).catch(log.error);
|
||||
}
|
||||
|
||||
public isBsRunning(): boolean{
|
||||
return this.bsProcess?.connected || this.utilsService.taskRunning(BS_EXECUTABLE) === true;
|
||||
public async isBsRunning(): Promise<boolean> {
|
||||
return this.bsProcess?.connected || await this.utilsService.taskRunning(BS_EXECUTABLE) === true;
|
||||
}
|
||||
|
||||
// TODO : Rework with shortcuts implementation
|
||||
@@ -121,4 +121,4 @@ export class BSLauncherService{
|
||||
return "LAUNCHED";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,8 +20,8 @@ export class OculusService {
|
||||
this.utils = UtilsService.getInstance();
|
||||
}
|
||||
|
||||
public oculusRunning(): boolean | null{
|
||||
return this.utils.taskRunning("OculusClient.exe");
|
||||
public async oculusRunning(): Promise<boolean> {
|
||||
return await this.utils.taskRunning("OculusClient.exe");
|
||||
}
|
||||
|
||||
public async getOculusLibsPath(): Promise<string[]>{
|
||||
@@ -64,4 +64,4 @@ export class OculusService {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import { readFile } from "fs/promises";
|
||||
import { spawn } from "child_process";
|
||||
import { pathExist } from "../helpers/fs.helpers";
|
||||
import log from "electron-log";
|
||||
import psList from 'ps-list';
|
||||
|
||||
export class SteamService{
|
||||
|
||||
@@ -25,18 +26,9 @@ export class SteamService{
|
||||
return SteamService.instance;
|
||||
}
|
||||
|
||||
public async getActiveUser(): Promise<number>{
|
||||
const res = await regedit.promisified.list(["HKCU\\Software\\Valve\\Steam\\ActiveProcess"]);
|
||||
const keys = res?.["HKCU\\Software\\Valve\\Steam\\ActiveProcess"];
|
||||
|
||||
if(!keys?.exists){ throw "Key \"HKCU\\Software\\Valve\\Steam\\ActiveProcess\" not exist"; }
|
||||
|
||||
return (keys.values?.ActiveUser.value || undefined) as number;
|
||||
}
|
||||
|
||||
public steamRunning(): Promise<boolean>{
|
||||
return this.getActiveUser()
|
||||
.then(userId => !!userId)
|
||||
public async steamRunning(): Promise<boolean>{
|
||||
return await psList()
|
||||
.then(processes => !!processes.find(process => process.cmd.includes('steam')))
|
||||
.catch(e => {log.error(e); throw e})
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import { app, BrowserWindow } from "electron";
|
||||
import { IpcResponse } from "shared/models/ipc";
|
||||
import log from "electron-log";
|
||||
import { AppWindow } from "shared/models/window-manager/app-window.model";
|
||||
import psList from "ps-list";
|
||||
|
||||
|
||||
// TODO : REFACTOR
|
||||
@@ -33,10 +34,10 @@ export class UtilsService{
|
||||
public setMainWindows(windows: Map<AppWindow, BrowserWindow>){ this.windows = windows; }
|
||||
public getMainWindows(win: AppWindow){ return this.windows.get(win); }
|
||||
|
||||
public taskRunning(task: string): boolean | null{
|
||||
public async taskRunning(task: string): Promise<boolean> {
|
||||
try{
|
||||
const tasks = spawnSync('tasklist').stdout;
|
||||
return tasks.toString().includes(task);
|
||||
const processes = await psList();
|
||||
return !!processes.find(process => process.cmd.includes(task));
|
||||
}
|
||||
catch(error){
|
||||
log.error(error);
|
||||
|
||||
Reference in New Issue
Block a user