diff --git a/src/index.tsx b/src/index.tsx index 5a7daaa..a342ba5 100755 --- a/src/index.tsx +++ b/src/index.tsx @@ -67,6 +67,7 @@ import { Cpus } from "./components/cpus"; var periodicHook: NodeJS.Timer | null = null; var lifetimeHook: any = null; var startHook: any = null; +var endHook: any = null; var usdplReady = false; type MinMax = { @@ -185,6 +186,12 @@ const reload = function() { ); }); + //@ts-ignore + endHook = SteamClient.Apps.RegisterForGameActionEnd((actionType) => { + backend.log(backend.LogLevel.Info, "RegisterForGameActionEnd callback(" + actionType + ")"); + setTimeout(() => backend.forceApplySettings(), 2000 /* ms */); + }); + backend.log(backend.LogLevel.Debug, "Registered PowerTools callbacks, hello!"); })(); @@ -321,8 +328,9 @@ export default definePlugin((serverApi: ServerAPI) => { backend.log(backend.LogLevel.Debug, "PowerTools shutting down"); clearInterval(periodicHook!); periodicHook = null; - lifetimeHook!.unregister(); - startHook!.unregister(); + lifetimeHook?.unregister(); + startHook?.unregister(); + endHook?.unregister(); //serverApi.routerHook.removeRoute("/decky-plugin-test"); backend.log(backend.LogLevel.Debug, "Unregistered PowerTools callbacks, so long and thanks for all the fish."); },