Fix wake detection, add more debug logging

This commit is contained in:
NGnius (Graham) 2022-09-11 11:37:26 -04:00
parent ef0a55b8ed
commit ba021c8f93
7 changed files with 18 additions and 11 deletions

View file

@ -14,7 +14,7 @@ You will need that installed for this plugin to work.
- Set GPU frequencies and power (fastPPT & slowPPT)
- Cap battery charge rate (when awake)
- 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

2
backend/Cargo.lock generated
View file

@ -567,7 +567,7 @@ dependencies = [
[[package]]
name = "powertools-rs"
version = "1.0.1"
version = "1.0.3"
dependencies = [
"log",
"serde",

View file

@ -1,6 +1,6 @@
[package]
name = "powertools-rs"
version = "1.0.2"
version = "1.0.3"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View file

@ -1,10 +1,10 @@
#!/bin/bash
cargo build --release --target x86_64-unknown-linux-musl
#cargo build --target x86_64-unknown-linux-musl
#cargo build --release --target x86_64-unknown-linux-musl
cargo build --target x86_64-unknown-linux-musl
#cross build --release
mkdir -p ../bin
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/release/powertools-rs ../bin/backend
cp ./target/x86_64-unknown-linux-musl/debug/powertools-rs ../bin/backend
#cp ./target/release/powertools-rs ../bin/backend

View file

@ -12,17 +12,20 @@ pub fn spawn(settings: Settings) -> JoinHandle<()> {
let duration = Duration::from_millis(5000);
let mut start = Instant::now();
loop {
thread::sleep(duration);
let old_start = start.elapsed();
start = Instant::now();
if old_start.as_secs_f64() > duration.as_secs_f64() * (1.0 + ALLOWED_ERROR) {
// has just resumed from sleep
log::info!("Resume detected");
unwrap_maybe_fatal(settings.on_resume(), "On resume failure");
log::debug!(
"OnResume completed after sleeping for {}s",
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!");
})

View file

@ -171,14 +171,18 @@ impl Settings {
impl OnResume for Settings {
fn on_resume(&self) -> Result<(), SettingError> {
log::debug!("Locking settings for 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");
for cpu in cpu_lock.iter_mut() {
let cpu_lock = unwrap_lock(self.cpus.lock(), "cpu");
log::debug!("Got cpus lock");
for cpu in cpu_lock.iter() {
cpu.on_resume()?;
}
}
unwrap_lock(self.gpu.lock(), "gpu").on_resume()?;
log::debug!("Got gpu lock");
Ok(())
}
}

View file

@ -1,6 +1,6 @@
{
"name": "PowerTools",
"version": "1.0.2",
"version": "1.0.3",
"description": "Power tweaks for power users",
"scripts": {
"build": "shx rm -rf dist && rollup -c",