BartoszCichecki / LenovoLegionToolkit

Lightweight Lenovo Vantage and Hotkeys replacement for Lenovo Legion laptops.
GNU General Public License v3.0
5.54k stars 249 forks source link

[FEAT]: At least once "At Specified Time" Action #760

Closed Ekscentricitet closed 1 year ago

Ekscentricitet commented 1 year ago

Version

Latest

OS

Windows 10

Device

Legion 5 Pro

Is your feature request related to a problem?

If the user has their laptop turned off or in Sleep mode, the trigger for At Specified Time will be missed. If the user wants to, for example, change the battery conservation mode, this might be a problem.

How would you like the problem to be solved?

Add a toggle setting in the Configuration window that operates on a bool property. If the switch is toggled on, makes the action execute at least once, even if the time for execution has passed. We would need another bool, let's call it IsExecuted, that will be used to determine if the action should be performed.

What alternatives have you considered?

Set a time period in which the action has to take place. The implementation is similar but instead of a toggle, the user specifies a start and end time. If this is something that is to be implemented, we can go further and make an action that forces the settings for the selected period of time. I don't see any practical use for that, unless somebody uses their laptop remotely and need something really specific to be happening in a specific time slot (think running some model overnight for 5 hours and putting everything on lowest settings after those 5 hours have expired). It will also be involved to implement since states will have to be checked (or set) on every itteration.

Additional information

No response

BartoszCichecki commented 1 year ago

While this is a neat idea, it opens up a dangerous rabbit hole that I do not want to jump into - the same concept could be applied to all other actions.

AutomationProcessor that own the pipelines simply reacts to events raised by different listeners and matches them with AutomationPipelines that are currently loaded into it. It uses deep copying heavily to avoid possible race conditions and as a result the constraint is that an AutomationPipeline has no concept of execytion state, neither do IAutomationTriggers, also neither should be mutated while loaded into the processor. Introducing state would be a major lift, because for example:

We would need another bool, let's call it IsExecuted, that will be used to determine if the action should be performed.

this IsExecuted flag would have to be cleared at some point, but when exactly? Each time LLT is restarted or actions are modified, AutomationProcessor sort of "restarts" to avoid desynchronizing it's internal state.

The conservation mode argument is often cited, but the truth is that, if the charge limit is an inconvenience, you should just not use conservation mode, because you obviously use the battery and conservation mode serves no purpose.