Update README, fix some per-game profile functionality
This commit is contained in:
parent
7158ac3596
commit
be0b871760
3 changed files with 26 additions and 3 deletions
20
README.md
20
README.md
|
@ -14,7 +14,7 @@ You will need that installed for this plugin to work.
|
||||||
- Set some GPU power parameters (fastPPT & slowPPT)
|
- Set some GPU power parameters (fastPPT & slowPPT)
|
||||||
- Set the fan RPM (unsupported on SteamOS beta)
|
- Set the fan RPM (unsupported on SteamOS beta)
|
||||||
- Display supplementary battery info
|
- Display supplementary battery info
|
||||||
- Keep settings between restarts (stored in `~/.config/powertools.json`)
|
- Keep settings between restarts (stored in `~/.config/powertools/<appid>.json`)
|
||||||
|
|
||||||
## Cool, but that's too much work
|
## Cool, but that's too much work
|
||||||
|
|
||||||
|
@ -79,6 +79,24 @@ This is how I figured out how the fan stuff works.
|
||||||
I've only scratched the surface of what this code allows, I'm sure it has more useful information.
|
I've only scratched the surface of what this code allows, I'm sure it has more useful information.
|
||||||
https://lkml.org/lkml/2022/2/5/391
|
https://lkml.org/lkml/2022/2/5/391
|
||||||
|
|
||||||
|
### Game launch detection
|
||||||
|
|
||||||
|
The biggest limitation right now is it can't detect a game closing -- only opening -- and only after PowerTools is looked at at least once (per SteamOS restart).
|
||||||
|
|
||||||
|
From a plugin, this can be accomplished by running some front-end Javascript.
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
await execute_in_tab("SP", false,
|
||||||
|
`SteamClient.Apps.RegisterForGameActionStart((actionType, data) => {
|
||||||
|
console.log("start game", appStore.GetAppOverviewByGameID(data));
|
||||||
|
});`
|
||||||
|
);
|
||||||
|
```
|
||||||
|
|
||||||
|
In PowerTools, the callback (the part surrounded by `{` and `}`, containing `console.log(...)`) sends a message to a local HTTP server to notify the PowerTools back-end that a game has been launched.
|
||||||
|
|
||||||
|
If you go to `http://127.0.0.1:5030` on your Steam Deck with PowerTools >=0.6.0, you can see some info about the last game you launched.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
This is licensed under GNU GPLv3.
|
This is licensed under GNU GPLv3.
|
||||||
|
|
3
main.py
3
main.py
|
@ -406,6 +406,9 @@ class Plugin:
|
||||||
self.current_gameid = current_game.gameid
|
self.current_gameid = current_game.gameid
|
||||||
self.modified_settings = True
|
self.modified_settings = True
|
||||||
else:
|
else:
|
||||||
|
if not enabled and current_game is not None and current_game.has_settings():
|
||||||
|
# delete settings; disable settings loading
|
||||||
|
os.remove(current_game.settings_path())
|
||||||
self.current_gameid = None
|
self.current_gameid = None
|
||||||
|
|
||||||
async def get_per_game_profile(self) -> bool:
|
async def get_per_game_profile(self) -> bool:
|
||||||
|
|
|
@ -64,11 +64,13 @@ class Server(web.Application):
|
||||||
logging.debug("Debug index page accessed")
|
logging.debug("Debug index page accessed")
|
||||||
current_game = None if self.current_game is None else self.current_game.gameid
|
current_game = None if self.current_game is None else self.current_game.gameid
|
||||||
game_info = None if self.current_game is None else self.current_game.game_info
|
game_info = None if self.current_game is None else self.current_game.game_info
|
||||||
|
settings_info = None if self.current_game is None else self.current_game.load_settings()
|
||||||
return web.json_response({
|
return web.json_response({
|
||||||
"name": "PowerTools",
|
"name": "PowerTools",
|
||||||
"version": self.version,
|
"version": self.version,
|
||||||
"latest_game_id": current_game,
|
"latest_game_id": current_game,
|
||||||
"game_info": game_info
|
"game_info": game_info,
|
||||||
|
"settings": settings_info
|
||||||
}, headers={"Access-Control-Allow-Origin": "*"})
|
}, headers={"Access-Control-Allow-Origin": "*"})
|
||||||
|
|
||||||
async def on_game_start(self, request):
|
async def on_game_start(self, request):
|
||||||
|
@ -125,7 +127,7 @@ async def start(version):
|
||||||
http_server = Server(version)
|
http_server = Server(version)
|
||||||
http_runner = web.AppRunner(http_server)
|
http_runner = web.AppRunner(http_server)
|
||||||
await http_runner.setup()
|
await http_runner.setup()
|
||||||
site = web.TCPSite(http_runner, '0.0.0.0', 5030)
|
site = web.TCPSite(http_runner, '127.0.0.1', 5030)
|
||||||
await site.start()
|
await site.start()
|
||||||
|
|
||||||
async def shutdown(): # never really called
|
async def shutdown(): # never really called
|
||||||
|
|
Loading…
Reference in a new issue