jurassicplayer / decky-autosuspend

A decky-loader plugin to automatically notify and suspend your steamdeck on low power.
Other
7 stars 0 forks source link

Activate critical state when battery is less than or equal #3

Closed ayesc9000 closed 1 year ago

ayesc9000 commented 1 year ago

At the current moment, the deck will be suspended when the battery is less than the threshold. Instead of checking whether the battery is less than the target, we should check whether it's less than or equal to.

I believe this would make more sense, as the slider in the settings for AutoSuspend displays that the critical threshold might be 5%, leading the user to expect their deck to be suspended at 5% battery. Instead, it will suspend at 4%, which might lead some users into thinking that the plugin didn't work.

jurassicplayer commented 1 year ago

There's one particular why I currently have it not trigger with less than or equal, and it's primarily to avoid having to attempt precise testing around the threshold because the one thing that I absolutely want to avoid is re-triggering suspend. Usually battery levels aren't an exact percentage and can fluctuate a little (no idea what the steamdeck's resolution is atm), but since it's generally not on the level of whole percentages, that's what I went with since I can guarantee AutoSuspend won't retrigger.

When I get the time, I'll probably take a look into the steamdeck's battery readings a bit closer and see how much they vary between suspends, and if it's got a pretty high resolution/consistent accuracy, I'll change the threshold's "deadzone" to be slimmer (threshold +/- 0.1% if the next digit is solid). At the moment though, I'm certain that your change would be able to cause re-triggering if the battery level shows any appreciable amount of fluctuation at the threshold (##.4%-##.5% since I round to the closest percent).

jurassicplayer commented 1 year ago

Turns out Steam's readings are pretty stable (at least for me in my less than one hand's worth of testing). Looks like something is providing them averages or something that gets updates every ~8 seconds. I set the deadzone to +/- 0.02% and made it somewhat easy for me to change how large it is just in case, but should accomplish about the same thing +/- a couple seconds.

It'll have the basically the behavior you're expecting in AutoSuspend v1.3.0+.

ayesc9000 commented 1 year ago

Cool, thanks.

jurassicplayer commented 1 year ago

@ayesc9000 There is now a new release v1.3.0 that includes the changes I mentioned. You can follow the manual installation instructions or just wait until it is added to the decky plugin store. It may not trigger a notification immediately after the percentage shown changes, but should happen within a small handful of seconds. If it seems excessively off, feel free to open up an issue.