Fix wake detection, add more debug logging
This commit is contained in:
parent
ef0a55b8ed
commit
ba021c8f93
7 changed files with 18 additions and 11 deletions
|
@ -14,7 +14,7 @@ You will need that installed for this plugin to work.
|
||||||
- Set GPU frequencies and power (fastPPT & slowPPT)
|
- Set GPU frequencies and power (fastPPT & slowPPT)
|
||||||
- Cap battery charge rate (when awake)
|
- Cap battery charge rate (when awake)
|
||||||
- Display supplementary battery info
|
- Display supplementary battery info
|
||||||
- Keep settings between restarts (stored in `~/.config/powertools/<appid>.json`)
|
- Keep settings between restarts (stored in `~/.config/powertools/<gameId>.json`)
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
|
|
2
backend/Cargo.lock
generated
2
backend/Cargo.lock
generated
|
@ -567,7 +567,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "powertools-rs"
|
name = "powertools-rs"
|
||||||
version = "1.0.1"
|
version = "1.0.3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"log",
|
"log",
|
||||||
"serde",
|
"serde",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "powertools-rs"
|
name = "powertools-rs"
|
||||||
version = "1.0.2"
|
version = "1.0.3"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
cargo build --release --target x86_64-unknown-linux-musl
|
#cargo build --release --target x86_64-unknown-linux-musl
|
||||||
#cargo build --target x86_64-unknown-linux-musl
|
cargo build --target x86_64-unknown-linux-musl
|
||||||
#cross build --release
|
#cross build --release
|
||||||
|
|
||||||
mkdir -p ../bin
|
mkdir -p ../bin
|
||||||
cp ./target/x86_64-unknown-linux-musl/release/powertools-rs ../bin/backend
|
#cp ./target/x86_64-unknown-linux-musl/release/powertools-rs ../bin/backend
|
||||||
#cp ./target/x86_64-unknown-linux-musl/debug/powertools-rs ../bin/backend
|
cp ./target/x86_64-unknown-linux-musl/debug/powertools-rs ../bin/backend
|
||||||
#cp ./target/release/powertools-rs ../bin/backend
|
#cp ./target/release/powertools-rs ../bin/backend
|
||||||
|
|
|
@ -12,17 +12,20 @@ pub fn spawn(settings: Settings) -> JoinHandle<()> {
|
||||||
let duration = Duration::from_millis(5000);
|
let duration = Duration::from_millis(5000);
|
||||||
let mut start = Instant::now();
|
let mut start = Instant::now();
|
||||||
loop {
|
loop {
|
||||||
thread::sleep(duration);
|
|
||||||
let old_start = start.elapsed();
|
let old_start = start.elapsed();
|
||||||
start = Instant::now();
|
start = Instant::now();
|
||||||
if old_start.as_secs_f64() > duration.as_secs_f64() * (1.0 + ALLOWED_ERROR) {
|
if old_start.as_secs_f64() > duration.as_secs_f64() * (1.0 + ALLOWED_ERROR) {
|
||||||
// has just resumed from sleep
|
// has just resumed from sleep
|
||||||
|
log::info!("Resume detected");
|
||||||
unwrap_maybe_fatal(settings.on_resume(), "On resume failure");
|
unwrap_maybe_fatal(settings.on_resume(), "On resume failure");
|
||||||
log::debug!(
|
log::debug!(
|
||||||
"OnResume completed after sleeping for {}s",
|
"OnResume completed after sleeping for {}s",
|
||||||
old_start.as_secs_f32()
|
old_start.as_secs_f32()
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
log::debug!("OnResume got sleep period of {}s", old_start.as_secs_f32());
|
||||||
}
|
}
|
||||||
|
thread::sleep(duration);
|
||||||
}
|
}
|
||||||
//log::warn!("resume_worker completed!");
|
//log::warn!("resume_worker completed!");
|
||||||
})
|
})
|
||||||
|
|
|
@ -171,14 +171,18 @@ impl Settings {
|
||||||
|
|
||||||
impl OnResume for Settings {
|
impl OnResume for Settings {
|
||||||
fn on_resume(&self) -> Result<(), SettingError> {
|
fn on_resume(&self) -> Result<(), SettingError> {
|
||||||
|
log::debug!("Locking settings for on_resume");
|
||||||
unwrap_lock(self.battery.lock(), "battery").on_resume()?;
|
unwrap_lock(self.battery.lock(), "battery").on_resume()?;
|
||||||
|
log::debug!("Got battery lock");
|
||||||
{
|
{
|
||||||
let mut cpu_lock = unwrap_lock(self.cpus.lock(), "cpu");
|
let cpu_lock = unwrap_lock(self.cpus.lock(), "cpu");
|
||||||
for cpu in cpu_lock.iter_mut() {
|
log::debug!("Got cpus lock");
|
||||||
|
for cpu in cpu_lock.iter() {
|
||||||
cpu.on_resume()?;
|
cpu.on_resume()?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unwrap_lock(self.gpu.lock(), "gpu").on_resume()?;
|
unwrap_lock(self.gpu.lock(), "gpu").on_resume()?;
|
||||||
|
log::debug!("Got gpu lock");
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "PowerTools",
|
"name": "PowerTools",
|
||||||
"version": "1.0.2",
|
"version": "1.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",
|
||||||
|
|
Loading…
Reference in a new issue