forked from NG-SD-Plugins/PowerTools
Compare commits
43 commits
Author | SHA1 | Date | |
---|---|---|---|
bf7b5617b2 | |||
fadf492aac | |||
921f360e9e | |||
1996eb7e16 | |||
6b7ce73a24 | |||
64dc319223 | |||
5f642a33e3 | |||
3f3241ed45 | |||
b100b1f2f2 | |||
f9e384d50c | |||
d23880bf4d | |||
579ee2ee85 | |||
decc0cd73d | |||
|
3de8a89c9b | ||
|
94e429e448 | ||
a7be114fd3 | |||
2878232ba4 | |||
eb4ec05425 | |||
|
760002f430 | ||
53f8867372 | |||
e27b330577 | |||
15833c82e9 | |||
fad17807e2 | |||
2c1321b544 | |||
2fef0d7dd1 | |||
c12a944316 | |||
74a9b723e6 | |||
68f8bfbc7f | |||
1a5a8ca352 | |||
33cd064667 | |||
4bf548152f | |||
c9557736ef | |||
5a71586095 | |||
23cf76f084 | |||
f879c82f33 | |||
05de36a082 | |||
1ca1148a4c | |||
b731ebddc5 | |||
5b6c5ec268 | |||
ab2eea5fb4 | |||
bfcdbf8742 | |||
0b89ed13ec | |||
f0862ddd73 |
21 changed files with 198 additions and 244 deletions
2
.github/FUNDING.yml
vendored
Normal file
2
.github/FUNDING.yml
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
github: NGnius
|
||||||
|
liberapay: NGnius
|
26
.github/ISSUE_TEMPLATE/bug-report.md
vendored
26
.github/ISSUE_TEMPLATE/bug-report.md
vendored
|
@ -1,26 +0,0 @@
|
||||||
---
|
|
||||||
name: Bug Report
|
|
||||||
about: Create a report to help us improve
|
|
||||||
title: ''
|
|
||||||
labels: bug
|
|
||||||
assignees: ''
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**Expected Behaviour**
|
|
||||||
A clear and concise description of what you expected to happen.
|
|
||||||
|
|
||||||
**Actual Behaviour**
|
|
||||||
A clear and concise description of what actually happened.
|
|
||||||
|
|
||||||
**To Reproduce**
|
|
||||||
Steps to reproduce the behavior:
|
|
||||||
1. Go to '...'
|
|
||||||
2. Click on '....'
|
|
||||||
3. Scroll down to '....'
|
|
||||||
4. See error
|
|
||||||
|
|
||||||
**Screenshots, etc.**
|
|
||||||
If applicable, add screenshots to help explain your problem.
|
|
||||||
Please include the log (located at `/tmp/powertools.log`) if possible.
|
|
||||||
Note: the log is deleted when the device is restarted.
|
|
72
.github/ISSUE_TEMPLATE/bug-report.yml
vendored
Normal file
72
.github/ISSUE_TEMPLATE/bug-report.yml
vendored
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
name: "Bug Report"
|
||||||
|
description: "Report an issue with PowerTools"
|
||||||
|
labels: "bug"
|
||||||
|
body:
|
||||||
|
- type: textarea
|
||||||
|
id: expected-behaviour
|
||||||
|
attributes:
|
||||||
|
label: Expected Behaviour
|
||||||
|
description: A clear and concise description of what you expected to happen.
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
id: actual-behaviour
|
||||||
|
attributes:
|
||||||
|
label: Actual Behaviour
|
||||||
|
description: A clear and concise description of what actually happened.
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
id: reproduction
|
||||||
|
attributes:
|
||||||
|
label: Steps To Reproduce
|
||||||
|
description: Steps to reproduce the behaviour.
|
||||||
|
placeholder: |
|
||||||
|
1. Go to '...'
|
||||||
|
2. Click on '....'
|
||||||
|
3. Scroll down to '.....'
|
||||||
|
4. See error......
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
id: extras
|
||||||
|
attributes:
|
||||||
|
label: Anything else?
|
||||||
|
description: |
|
||||||
|
Screenshots? Logs? limits_overrides.ron? limits_cache.ron? Anything that will give more context about the problem!
|
||||||
|
If applicable, add screenshots to help explain your problem.
|
||||||
|
Please include the log (located at `/tmp/powertools.log`) if possible.
|
||||||
|
Note: the log is deleted when the device is restarted.
|
||||||
|
|
||||||
|
Tip: You can attach files by clicking this area to highlight it and then dragging them in.
|
||||||
|
validations:
|
||||||
|
required: false
|
||||||
|
- type: input
|
||||||
|
id: version
|
||||||
|
attributes:
|
||||||
|
label: Version
|
||||||
|
description: What version of PowerTools are you using? This is the version beside `Native` near the bottom of the plugin's UI.
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: input
|
||||||
|
id: platform
|
||||||
|
attributes:
|
||||||
|
label: Platform
|
||||||
|
description: What driver is PowerTools using?
|
||||||
|
value: SteamDeck
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: dropdown
|
||||||
|
id: operating-system
|
||||||
|
attributes:
|
||||||
|
label: OS
|
||||||
|
description: On which operating system are you running PowerTools?
|
||||||
|
options:
|
||||||
|
- _
|
||||||
|
- SteamOS 3 (Stable)
|
||||||
|
- SteamOS 3 (Preview/Beta)
|
||||||
|
- SteamOS 3 (Main)
|
||||||
|
- HoloISO
|
||||||
|
- Not listed
|
||||||
|
validations:
|
||||||
|
required: true
|
5
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
5
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
blank_issues_enabled: false
|
||||||
|
contact_links:
|
||||||
|
- name: NGnius
|
||||||
|
url: https://git.ngni.us/sys/website/wiki#contact-information
|
||||||
|
about: Repository owner
|
17
.github/ISSUE_TEMPLATE/feature-request.md
vendored
17
.github/ISSUE_TEMPLATE/feature-request.md
vendored
|
@ -1,17 +0,0 @@
|
||||||
---
|
|
||||||
name: Feature Request
|
|
||||||
about: Suggest a tool to add
|
|
||||||
title: ''
|
|
||||||
labels: enhancement
|
|
||||||
assignees: ''
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**Describe what you'd like to be able to do**
|
|
||||||
A clear and concise description of what you want. E.g. I'd like to be able to select how many CPU cores are enabled.
|
|
||||||
|
|
||||||
**Describe alternatives you've considered**
|
|
||||||
A clear and concise description of any alternatives you've considered. E.g. Enabling and disabling CPU cores with another computer connected over SSH.
|
|
||||||
|
|
||||||
**Additional context**
|
|
||||||
Description of how can this be done. E.g. This can be accomplished with `echo {0 or 1} > /sys/devices/system/cpu/cpu{cpu_number}/online`.
|
|
32
.github/ISSUE_TEMPLATE/feature-request.yml
vendored
Normal file
32
.github/ISSUE_TEMPLATE/feature-request.yml
vendored
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
name: Feature Request
|
||||||
|
description: Suggest functionality to add
|
||||||
|
labels: "enhancement"
|
||||||
|
body:
|
||||||
|
- type: textarea
|
||||||
|
id: feature-description
|
||||||
|
attributes:
|
||||||
|
label: Describe what you'd like to be able to do
|
||||||
|
description: A clear and concise description of what you want.
|
||||||
|
placeholder: I'd like to be able to ...
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
id: alternatives
|
||||||
|
attributes:
|
||||||
|
label: Describe alternatives you've considered
|
||||||
|
description: A clear and concise description of any alternatives you've considered.
|
||||||
|
placeholder: This can also be done by ... but ...
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
id: extras
|
||||||
|
attributes:
|
||||||
|
label: Anything else?
|
||||||
|
description: |
|
||||||
|
Description of how this can be achieved, or other additional context.
|
||||||
|
If this is related to the UI, consider adding a picture.
|
||||||
|
|
||||||
|
Tip: You can attach files by clicking this area to highlight it and then dragging them in.
|
||||||
|
placeholder: This can be accomplished by doing ...
|
||||||
|
validations:
|
||||||
|
required: false
|
23
.github/ISSUE_TEMPLATE/question.yml
vendored
Normal file
23
.github/ISSUE_TEMPLATE/question.yml
vendored
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
name: "Question"
|
||||||
|
description: "Ask for more information about PowerTools"
|
||||||
|
labels: "question"
|
||||||
|
body:
|
||||||
|
- type: textarea
|
||||||
|
id: question-elaboration
|
||||||
|
attributes:
|
||||||
|
label: Question
|
||||||
|
description: |
|
||||||
|
A clear and concise description of what you'd like to know.
|
||||||
|
Please check the wiki and closed issues to avoid waiting for an answer when you didn't need to.
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
id: extras
|
||||||
|
attributes:
|
||||||
|
label: Extra Info
|
||||||
|
description: |
|
||||||
|
Additional context or information which may be helpful when answering your question.
|
||||||
|
|
||||||
|
Tip: You can attach files by clicking this area to highlight it and then dragging them in.
|
||||||
|
validations:
|
||||||
|
required: false
|
13
.github/pull_request_template.md
vendored
Normal file
13
.github/pull_request_template.md
vendored
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
## Description
|
||||||
|
|
||||||
|
A short description of what the PR changes.
|
||||||
|
If this is a minor change and the commit message(s) explains it well, feel free to delete this section.
|
||||||
|
|
||||||
|
## Motivation
|
||||||
|
|
||||||
|
Why did you write this PR and/or why should it be accepted.
|
||||||
|
|
||||||
|
## Fixes
|
||||||
|
|
||||||
|
Please indicate issues that this fixes or addresses here.
|
||||||
|
If this is a bugfix with no pre-existing issue, please describe the bug here instead.
|
28
README.md
28
README.md
|
@ -1,12 +1,12 @@
|
||||||
# PowerTools
|
# PowerTools
|
||||||
<!-- TODO Update badges for new git repo location -->
|
<!-- TODO Update badges for new git repo location -->
|
||||||
[![Decky store](https://img.shields.io/badge/dynamic/json?color=blue&label=release&query=%24%5B%3F%28%40.name%3D%3D%27PowerTools%27%29%5D.versions%5B0%5D.name&url=https%3A%2F%2Fplugins.deckbrew.xyz%2Fplugins&style=flat-square)](https://plugins.deckbrew.xyz/)
|
[![Decky store](https://img.shields.io/badge/dynamic/json?color=blue&label=release&query=%24%5B%3F%28%40.name%3D%3D%27PowerTools%27%29%5D.versions%5B0%5D.name&url=https%3A%2F%2Fplugins.deckbrew.xyz%2Fplugins&style=flat-square)](https://plugins.deckbrew.xyz/)
|
||||||
[![Custom store](https://img.shields.io/badge/dynamic/json?color=blue&label=preview&query=%24%5B%3F%28%40.name%3D%3D%27PowerTools%27%29%5D.versions%5B0%5D.name&url=https%3A%2F%2Fnot-decky-alpha.ngni.us%2Fplugins&style=flat-square)](https://github.com/NGnius/PowerTools/wiki)
|
[![Custom store](https://img.shields.io/badge/dynamic/json?color=blue&label=preview&query=%24%5B%3F%28%40.name%3D%3D%27PowerTools%27%29%5D.versions%5B0%5D.name&url=https%3A%2F%2Fnot-decky-alpha.ngni.us%2Fplugins&style=flat-square)](https://git.ngni.us/NG-SD-Plugins/PowerTools/wiki)
|
||||||
[![GitHub package.json version](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fgit.ngni.us%2FNG-SD-Plugins%2FPowerTools%2Fraw%2Fbranch%2Fmain%2Fpackage.json&query=%24.version&style=flat-square&label=local&cacheSeconds=600)](https://git.ngni.us/NG-SD-Plugins/PowerTools/src/branch/main/package.json)
|
[![GitHub package.json version](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fgit.ngni.us%2FNG-SD-Plugins%2FPowerTools%2Fraw%2Fbranch%2Fmain%2Fpackage.json&query=%24.version&style=flat-square&label=local&cacheSeconds=600)](https://git.ngni.us/NG-SD-Plugins/PowerTools/src/branch/main/package.json)
|
||||||
|
|
||||||
[![Liberapay](https://img.shields.io/liberapay/patrons/NGnius?style=flat-square)](https://liberapay.com/NGnius)
|
[![Liberapay](https://img.shields.io/liberapay/patrons/NGnius?style=flat-square)](https://liberapay.com/NGnius)
|
||||||
[![GitHub](https://img.shields.io/badge/GPL--3.0-orange?style=flat-square&label=license&cacheSeconds=600)](https://github.com/NGnius/PowerTools/blob/main/LICENSE)
|
[![GitHub](https://img.shields.io/badge/GPL--3.0-orange?style=flat-square&label=license&cacheSeconds=600)](https://git.ngni.us/NG-SD-Plugins/PowerTools/blob/main/LICENSE)
|
||||||
[![GitHub package.json dependency version (local)](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fgit.ngni.us%2FNG-SD-Plugins%2FPowerTools%2Fraw%2Fbranch%2Fmain%2Fpackage.json&query=%24..%5B'decky-frontend-lib'%5D&style=flat-square&label=decky-frontend-lib&cacheSeconds=600)](https://github.com/NGnius/PowerTools/blob/main/pnpm-lock.yaml)
|
[![GitHub package.json dependency version (local)](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fgit.ngni.us%2FNG-SD-Plugins%2FPowerTools%2Fraw%2Fbranch%2Fmain%2Fpackage.json&query=%24..%5B'decky-frontend-lib'%5D&style=flat-square&label=decky-frontend-lib&cacheSeconds=600)](https://git.ngni.us/NG-SD-Plugins/PowerTools/blob/main/pnpm-lock.yaml)
|
||||||
|
|
||||||
![plugin_demo](./assets/ui.png)
|
![plugin_demo](./assets/ui.png)
|
||||||
|
|
||||||
|
@ -20,24 +20,38 @@ You will need that installed for this plugin to work.
|
||||||
- Enable & disable CPU threads & SMT
|
- Enable & disable CPU threads & SMT
|
||||||
- Set CPU frequencies
|
- Set CPU frequencies
|
||||||
- Set GPU frequencies and power (fastPPT & slowPPT)
|
- Set GPU frequencies and power (fastPPT & slowPPT)
|
||||||
- Cap battery charge rate (when awake)
|
- Cap battery charge level
|
||||||
- Display supplementary battery info
|
- Display supplementary battery info
|
||||||
- Keep settings between restarts (stored in `~/.config/powertools/<gameId>.json`)
|
- Keep settings between restarts (stored in `~/homebrew/settings/PowerTools/<appId>.ron`)
|
||||||
|
|
||||||
This plugin is tested on Steam Deck, but is designed to work on other Linux devices as well. Unfortunately I am currently unable to test on other devices.
|
This plugin is tested on Steam Deck LCD/OLED, but is designed to work on other Linux devices as well. Unfortunately I am currently unable to test on most other devices.
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
Please use Decky's [built-in store](https://plugins.deckbrew.xyz/) to install official releases.
|
Please use Decky's [built-in store](https://plugins.deckbrew.xyz/) to install official releases.
|
||||||
If you want to test unstable versions, use [my custom store](https://not-decky-alpha.ngni.us/plugins). If you would like to use an in-development version, feel free to build PowerTools yourself.
|
If you want to test unstable versions, use [my custom store](https://not-decky-alpha.ngni.us/plugins). If you would like to use an in-development version, feel free to build PowerTools yourself.
|
||||||
|
|
||||||
## Build
|
## Build/Deploy
|
||||||
|
|
||||||
0. Requirements: a functioning Rust toolchain for x86_64-unknown-linux-gnu (or -musl), pnpm, and some tech literacy
|
0. Requirements: a functioning Rust toolchain for x86_64-unknown-linux-gnu (or -musl), pnpm, and some tech literacy
|
||||||
1. In a terminal, navigate to the backend directory of this project and run `./build.sh`
|
1. In a terminal, navigate to the backend directory of this project and run `./build.sh`
|
||||||
2. In the root of this project, run `pnpm run build`
|
2. In the root of this project, run `pnpm run build`
|
||||||
3. Transfer the project (especially dist/ and bin/) to a folder in your Steam Deck's `~/homebrew/plugins` directory
|
3. Transfer the project (especially dist/ and bin/) to a folder in your Steam Deck's `~/homebrew/plugins` directory
|
||||||
|
4. Restart Decky with `sudo systemctl restart plugin_loader.service`
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
This is licensed under GNU GPLv3.
|
This is licensed under GNU GPLv3.
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
|
||||||
|
All contributions are welcome!
|
||||||
|
Anything from a comment on an issue to a new feature pull request will be appreciated by PowerTools's crack team of one (NGnius).
|
||||||
|
|
||||||
|
### Translations
|
||||||
|
|
||||||
|
Adding new languages and keeping existing language files up to date makes PowerTools more accessible to the majority of the world which doesn't speak English. Take a look at [this comment](https://git.ngni.us/NG-SD-Plugins/PowerTools/issues/9#issuecomment-345) (and the rest of that issue) to get started.
|
||||||
|
|
||||||
|
### Code
|
||||||
|
|
||||||
|
To prevent spam, this server does not allow regular users to create/fork repositories. Please open an issue [here](https://git.ngni.us/sys/website) to request permission. There's no pressure to actually do anything with that permission, though it may be revoked when the server is running low on space.
|
||||||
|
|
20
backend/Cargo.lock
generated
20
backend/Cargo.lock
generated
|
@ -891,22 +891,22 @@ dependencies = [
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libryzenadj"
|
name = "libryzenadj-alt"
|
||||||
version = "0.13.0"
|
version = "0.14.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c5bccdf07c3234c06c435648a53d8cb369f76d20e03bb8d2f8c24fb2330efc32"
|
checksum = "f0a8cc66a7f77b864c2ef014dd9f9a3b03305d9e7f130202ca4addde9bc71f8b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"errno",
|
"errno",
|
||||||
"libryzenadj-sys",
|
"libryzenadj-sys-alt",
|
||||||
"num_enum",
|
"num_enum",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libryzenadj-sys"
|
name = "libryzenadj-sys-alt"
|
||||||
version = "0.13.0"
|
version = "0.14.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b1de3621be974e892e12d4a07a6a2e32b6a05950759b062d94f5b54f78fabc3a"
|
checksum = "cb9de62ac92216770e51b5fa0628c22246a23c948e006f4ee65f6b96f6e0dd35"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bindgen",
|
"bindgen",
|
||||||
"cmake",
|
"cmake",
|
||||||
|
@ -1170,14 +1170,14 @@ checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "powertools"
|
name = "powertools"
|
||||||
version = "2.0.3-alpha1"
|
version = "2.0.3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"chrono",
|
"chrono",
|
||||||
"clap",
|
"clap",
|
||||||
"community_settings_core",
|
"community_settings_core",
|
||||||
"libc",
|
"libc",
|
||||||
"libryzenadj",
|
"libryzenadj-alt",
|
||||||
"limits_core",
|
"limits_core",
|
||||||
"log",
|
"log",
|
||||||
"regex",
|
"regex",
|
||||||
|
@ -1482,6 +1482,8 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "smokepatio"
|
name = "smokepatio"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3416e8c907d171c4334df3933873c32bff97ca5ad7ae0ee93e6268e04e2041ef"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"embedded-io",
|
"embedded-io",
|
||||||
"log",
|
"log",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "powertools"
|
name = "powertools"
|
||||||
version = "2.0.3-alpha1"
|
version = "2.0.3"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
authors = ["NGnius (Graham) <ngniusness@gmail.com>"]
|
authors = ["NGnius (Graham) <ngniusness@gmail.com>"]
|
||||||
description = "Backend (superuser) functionality for PowerTools"
|
description = "Backend (superuser) functionality for PowerTools"
|
||||||
|
@ -31,7 +31,7 @@ limits_core = { version = "3", path = "./limits_core" }
|
||||||
regex = "1"
|
regex = "1"
|
||||||
|
|
||||||
# steam deck libs
|
# steam deck libs
|
||||||
smokepatio = { version = "0.2", default-features = false, path = "../../smokepatio" }
|
smokepatio = { version = "0.2", default-features = false }
|
||||||
libc = "0.2"
|
libc = "0.2"
|
||||||
|
|
||||||
# online settings
|
# online settings
|
||||||
|
@ -40,7 +40,7 @@ chrono = { version = "0.4", features = [ "serde" ] }
|
||||||
|
|
||||||
# hardware enablement
|
# hardware enablement
|
||||||
#libryzenadj = { version = "0.14", path = "../../libryzenadj-rs-14" }
|
#libryzenadj = { version = "0.14", path = "../../libryzenadj-rs-14" }
|
||||||
libryzenadj = { version = "0.13" }
|
libryzenadj-alt = { version = "0.14" }
|
||||||
|
|
||||||
# ureq's tls feature does not like musl targets
|
# ureq's tls feature does not like musl targets
|
||||||
ureq = { version = "2", features = ["json", "gzip", "brotli", "charset", "tls"], default-features = false, optional = true }
|
ureq = { version = "2", features = ["json", "gzip", "brotli", "charset", "tls"], default-features = false, optional = true }
|
||||||
|
|
|
@ -23,7 +23,7 @@ pub enum ApiMessage {
|
||||||
OnChargeChange(f64), // battery fill amount: 0 = empty, 1 = full
|
OnChargeChange(f64), // battery fill amount: 0 = empty, 1 = full
|
||||||
PowerVibeCheck,
|
PowerVibeCheck,
|
||||||
WaitForEmptyQueue(Callback<()>),
|
WaitForEmptyQueue(Callback<()>),
|
||||||
LoadSettings(Option<(u64, String)>, Option<(u64, String, u64, String)>), // (legacy(game_id, name), current(path, name, variant, variant name))
|
LoadSettings(u64, String, u64, String), // (path, name, variant, variant name)
|
||||||
LoadVariant(u64, String), // (variant, variant name) -- path and name assumed to be for current profile
|
LoadVariant(u64, String), // (variant, variant name) -- path and name assumed to be for current profile
|
||||||
LoadMainSettings,
|
LoadMainSettings,
|
||||||
LoadSystemSettings,
|
LoadSystemSettings,
|
||||||
|
@ -45,21 +45,13 @@ impl core::fmt::Display for ApiMessage {
|
||||||
Self::OnChargeChange(x) => write!(f, "OnChargeChange({:?})", x),
|
Self::OnChargeChange(x) => write!(f, "OnChargeChange({:?})", x),
|
||||||
Self::PowerVibeCheck => write!(f, "PowerVibeCheck"),
|
Self::PowerVibeCheck => write!(f, "PowerVibeCheck"),
|
||||||
Self::WaitForEmptyQueue(_) => write!(f, "WaitForEmptyQueue"),
|
Self::WaitForEmptyQueue(_) => write!(f, "WaitForEmptyQueue"),
|
||||||
Self::LoadSettings(path, name, variant, variant_name) => write!(
|
Self::LoadSettings(path, name, variant, variant_name) => write!(f, "LoadSettings({}, {}, {}, {})", path, name, variant, variant_name),
|
||||||
f,
|
Self::LoadVariant(variant, variant_name) => write!(f, "LoadVariant({}, {})", variant, variant_name),
|
||||||
"LoadSettings({}, {}, {}, {})",
|
|
||||||
path, name, variant, variant_name
|
|
||||||
),
|
|
||||||
Self::LoadVariant(variant, variant_name) => {
|
|
||||||
write!(f, "LoadVariant({}, {})", variant, variant_name)
|
|
||||||
}
|
|
||||||
Self::LoadMainSettings => write!(f, "LoadMainSettings"),
|
Self::LoadMainSettings => write!(f, "LoadMainSettings"),
|
||||||
Self::LoadSystemSettings => write!(f, "LoadSystemSettings"),
|
Self::LoadSystemSettings => write!(f, "LoadSystemSettings"),
|
||||||
Self::GetLimits(_) => write!(f, "GetLimits"),
|
Self::GetLimits(_) => write!(f, "GetLimits"),
|
||||||
Self::GetProvider(s, _) => write!(f, "GetProvider({})", s),
|
Self::GetProvider(s, _) => write!(f, "GetProvider({})", s),
|
||||||
Self::UploadCurrentVariant(id, user) => {
|
Self::UploadCurrentVariant(id, user) => write!(f, "UploadCurrentVariant(id: {}, user: {})", id, user),
|
||||||
write!(f, "UploadCurrentVariant(id: {}, user: {})", id, user)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -400,7 +392,9 @@ impl ApiMessageHandler {
|
||||||
messages.push(msg.to_string());
|
messages.push(msg.to_string());
|
||||||
dirty |= self.process(settings, msg);
|
dirty |= self.process(settings, msg);
|
||||||
}
|
}
|
||||||
if dirty || dirty_echo {
|
if dirty
|
||||||
|
|| dirty_echo
|
||||||
|
{
|
||||||
dirty_echo = dirty; // echo only once
|
dirty_echo = dirty; // echo only once
|
||||||
print_messages(&messages);
|
print_messages(&messages);
|
||||||
// run on_set
|
// run on_set
|
||||||
|
@ -504,61 +498,7 @@ impl ApiMessageHandler {
|
||||||
self.on_empty.push(callback);
|
self.on_empty.push(callback);
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
ApiMessage::LoadSettings(legacy_settings, current_settings) => {
|
ApiMessage::LoadSettings(id, name, variant_id, variant_name) => {
|
||||||
/* Migration steps:
|
|
||||||
1. Modify to the frontend to send the game ID in this message (`id` here is the app
|
|
||||||
ID).
|
|
||||||
2. Change game ID to app ID.
|
|
||||||
3. (Create and) call function to merge OldSettingsJson with existing FileJson, or
|
|
||||||
use existing `From<OldSettingsJson> for FileJson` if this game doesn't have a
|
|
||||||
save in the new format yet.
|
|
||||||
4. Let the rest of the code below work its magic.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// ===== migration logic =====
|
|
||||||
if legacy_settings.is_some() {
|
|
||||||
let (legacy_game_id, legacy_name) = legacy_settings.unwrap();
|
|
||||||
|
|
||||||
let legacy_file_path = format!("{legacy_game_id}.json");
|
|
||||||
let legacy_file = crate::persist::OldSettingsJson::open(legacy_file_path)
|
|
||||||
.expect("should be able to deserialzie legacy savefile format"); // TODO: don't panic on fail.
|
|
||||||
|
|
||||||
if current_settings.is_some() {
|
|
||||||
// A savefile in both the legacy and current format exist.
|
|
||||||
let (id, name, variant_id, variant_name) = current_settings.unwrap();
|
|
||||||
let path = format!("{}.ron", id);
|
|
||||||
|
|
||||||
// 1. Parse `legacy_file` to into a settings variant.
|
|
||||||
let migrated_settings_variant: crate::persist::SettingsJson =
|
|
||||||
legacy_file.into();
|
|
||||||
// 2. Insert the variant into the current settings file.
|
|
||||||
match settings.load_file(
|
|
||||||
path.into(),
|
|
||||||
id,
|
|
||||||
name,
|
|
||||||
variant_id,
|
|
||||||
variant_name,
|
|
||||||
false,
|
|
||||||
) {
|
|
||||||
Ok(success) => log::info!("Loaded settings file? {}", success),
|
|
||||||
Err(e) => log::warn!("Load file err: {}", e),
|
|
||||||
}
|
|
||||||
settings.add_variant() //TODO: This.
|
|
||||||
} else {
|
|
||||||
// A savefile in the current format doesn't exist yet.
|
|
||||||
// TODO: Parse it to the new format and save it.
|
|
||||||
|
|
||||||
let app_id_from_game_id: u64;
|
|
||||||
let new_path = format!("{app_id_from_game_id}.ron");
|
|
||||||
|
|
||||||
let migrated_settings: crate::persist::FileJson = legacy_file.into();
|
|
||||||
migrated_settings.save(new_path);
|
|
||||||
}
|
|
||||||
} else if current_settings.is_some() {
|
|
||||||
// ...
|
|
||||||
}
|
|
||||||
// ===========================
|
|
||||||
|
|
||||||
let path = format!("{}.ron", id);
|
let path = format!("{}.ron", id);
|
||||||
if let Err(e) = settings.on_unload() {
|
if let Err(e) = settings.on_unload() {
|
||||||
print_errors("LoadSettings on_unload()", e);
|
print_errors("LoadSettings on_unload()", e);
|
||||||
|
|
|
@ -36,14 +36,6 @@ impl From<ron::error::Error> for RonError {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<serde_json::Error> for RonError {
|
|
||||||
fn from(_value: serde_json::Error) -> Self {
|
|
||||||
RonError::General(ron::Error::Message(String::from(
|
|
||||||
"TODO: make error handling in migration logic good. Specifically, make it so a json error can be used as a RonError instead of just returning this string",
|
|
||||||
)))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<ron::error::SpannedError> for RonError {
|
impl From<ron::error::SpannedError> for RonError {
|
||||||
fn from(value: ron::error::SpannedError) -> Self {
|
fn from(value: ron::error::SpannedError) -> Self {
|
||||||
Self::Spanned(value)
|
Self::Spanned(value)
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
pub mod gpu;
|
|
||||||
pub mod settings;
|
|
||||||
|
|
||||||
pub const APP_ID_UNKNOWN: u64 = u64::MAX;
|
|
|
@ -1,26 +0,0 @@
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
|
|
||||||
use crate::persist::{GpuJson, MinMaxJson};
|
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone)]
|
|
||||||
pub struct OldGpuJson {
|
|
||||||
pub fast_ppt: Option<u64>,
|
|
||||||
pub slow_ppt: Option<u64>,
|
|
||||||
pub clock_limits: Option<MinMaxJson<u64>>,
|
|
||||||
pub slow_memory: bool,
|
|
||||||
pub root: Option<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<OldGpuJson> for GpuJson {
|
|
||||||
fn from(old_gpu: OldGpuJson) -> Self {
|
|
||||||
Self {
|
|
||||||
fast_ppt: old_gpu.fast_ppt,
|
|
||||||
slow_ppt: old_gpu.slow_ppt,
|
|
||||||
tdp: None,
|
|
||||||
tdp_boost: None,
|
|
||||||
clock_limits: old_gpu.clock_limits.clone(),
|
|
||||||
memory_clock: None,
|
|
||||||
root: old_gpu.root.clone(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,67 +0,0 @@
|
||||||
use std::collections::HashMap;
|
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
|
|
||||||
use crate::persist::{
|
|
||||||
BatteryJson, CpuJson, DriverJson, FileJson, SerdeError, SettingsJson, LATEST_VERSION,
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::gpu::OldGpuJson;
|
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone)]
|
|
||||||
pub struct OldOnEventJson {
|
|
||||||
pub on_save: Option<String>,
|
|
||||||
pub on_load: Option<String>,
|
|
||||||
pub on_set: Option<String>,
|
|
||||||
pub on_resume: Option<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone)]
|
|
||||||
pub struct OldSettingsJson {
|
|
||||||
pub version: u64,
|
|
||||||
pub name: String,
|
|
||||||
pub persistent: bool,
|
|
||||||
pub cpus: Vec<CpuJson>,
|
|
||||||
pub gpu: OldGpuJson,
|
|
||||||
pub battery: BatteryJson,
|
|
||||||
pub provider: Option<DriverJson>,
|
|
||||||
pub events: Option<OldOnEventJson>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<OldSettingsJson> for SettingsJson {
|
|
||||||
fn from(old_settings: OldSettingsJson) -> Self {
|
|
||||||
Self {
|
|
||||||
version: old_settings.version,
|
|
||||||
name: format!("{} (migrated)", old_settings.name.clone()),
|
|
||||||
variant: 0,
|
|
||||||
persistent: old_settings.persistent,
|
|
||||||
cpus: old_settings.cpus.clone(),
|
|
||||||
gpu: old_settings.gpu.clone().into(),
|
|
||||||
battery: old_settings.battery.clone(),
|
|
||||||
provider: old_settings.provider.clone(),
|
|
||||||
tags: Vec::new(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<OldSettingsJson> for FileJson {
|
|
||||||
fn from(old_settings: OldSettingsJson) -> Self {
|
|
||||||
let mut variants = HashMap::new();
|
|
||||||
let variant = SettingsJson::from(old_settings.clone());
|
|
||||||
variants.insert(0, variant);
|
|
||||||
|
|
||||||
Self {
|
|
||||||
version: LATEST_VERSION,
|
|
||||||
name: old_settings.name.clone(),
|
|
||||||
app_id: super::APP_ID_UNKNOWN, // `u64::MAX`, sentinel value.
|
|
||||||
variants,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl OldSettingsJson {
|
|
||||||
pub fn open<P: AsRef<std::path::Path>>(path: P) -> Result<Self, SerdeError> {
|
|
||||||
let mut file = std::fs::File::open(path).map_err(SerdeError::Io)?;
|
|
||||||
serde_json::from_reader(&mut file).map_err(|e| SerdeError::Serde(e.into()))
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -5,7 +5,6 @@ mod error;
|
||||||
mod file;
|
mod file;
|
||||||
mod general;
|
mod general;
|
||||||
mod gpu;
|
mod gpu;
|
||||||
mod migration;
|
|
||||||
|
|
||||||
pub use battery::{BatteryEventJson, BatteryJson};
|
pub use battery::{BatteryEventJson, BatteryJson};
|
||||||
pub use cpu::CpuJson;
|
pub use cpu::CpuJson;
|
||||||
|
@ -13,8 +12,7 @@ pub use driver::DriverJson;
|
||||||
pub use file::FileJson;
|
pub use file::FileJson;
|
||||||
pub use general::{MinMaxJson, SettingsJson};
|
pub use general::{MinMaxJson, SettingsJson};
|
||||||
pub use gpu::GpuJson;
|
pub use gpu::GpuJson;
|
||||||
pub use migration::{gpu::*, settings::*};
|
|
||||||
|
|
||||||
pub use error::{RonError, SerdeError};
|
pub use error::SerdeError;
|
||||||
|
|
||||||
pub const LATEST_VERSION: u64 = 0;
|
pub const LATEST_VERSION: u64 = 0;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use libryzenadj::RyzenAdj;
|
use libryzenadj_alt::RyzenAdj;
|
||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
|
|
||||||
use crate::persist::GpuJson;
|
use crate::persist::GpuJson;
|
||||||
|
@ -22,9 +22,9 @@ fn msg_or_err<D: std::fmt::Display, E: std::fmt::Display>(
|
||||||
fn log_capabilities(ryzenadj: &RyzenAdj) {
|
fn log_capabilities(ryzenadj: &RyzenAdj) {
|
||||||
log::info!(
|
log::info!(
|
||||||
"RyzenAdj v{}.{}.{}",
|
"RyzenAdj v{}.{}.{}",
|
||||||
libryzenadj::libryzenadj_sys::RYZENADJ_REVISION_VER,
|
libryzenadj_alt::libryzenadj_sys::RYZENADJ_REVISION_VER,
|
||||||
libryzenadj::libryzenadj_sys::RYZENADJ_MAJOR_VER,
|
libryzenadj_alt::libryzenadj_sys::RYZENADJ_MAJOR_VER,
|
||||||
libryzenadj::libryzenadj_sys::RYZENADJ_MINIOR_VER
|
libryzenadj_alt::libryzenadj_sys::RYZENADJ_MINIOR_VER
|
||||||
);
|
);
|
||||||
#[cfg(feature = "experimental")]
|
#[cfg(feature = "experimental")]
|
||||||
if let Some(x) = ryzenadj.get_init_table_err() {
|
if let Some(x) = ryzenadj.get_init_table_err() {
|
||||||
|
|
|
@ -59,6 +59,7 @@ mod test {
|
||||||
online: status,
|
online: status,
|
||||||
clock_limits: None,
|
clock_limits: None,
|
||||||
governor: "schedutil".to_owned(),
|
governor: "schedutil".to_owned(),
|
||||||
|
root: Some("/".to_owned()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "PowerTools",
|
"name": "PowerTools",
|
||||||
"version": "2.0.3-alpha1",
|
"version": "2.0.3",
|
||||||
"description": "Power tweaks for power users",
|
"description": "Power tweaks for power users",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "shx rm -rf dist && rollup -c",
|
"build": "shx rm -rf dist && rollup -c",
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "PowerTools",
|
"name": "PowerTools",
|
||||||
"author": "NGnius",
|
"author": "NGnius",
|
||||||
"flags": ["root", "_debug", "global-dfl"],
|
"flags": ["root", "global-dfl"],
|
||||||
"publish": {
|
"publish": {
|
||||||
"discord_id": "106537989684887552",
|
"discord_id": "106537989684887552",
|
||||||
"description": "Power tweaks for power users",
|
"description": "Power tweaks for power users",
|
||||||
|
|
Loading…
Reference in a new issue