Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Suggestion] Script-based event handling #36

Closed
ldstein opened this issue Nov 25, 2021 · 2 comments · Fixed by #108
Closed

[Suggestion] Script-based event handling #36

ldstein opened this issue Nov 25, 2021 · 2 comments · Fixed by #108
Assignees
Labels
feature New feature or request

Comments

@ldstein
Copy link

ldstein commented Nov 25, 2021

Hi,

Let me preface this by thanking you and @ViRb3 for the great work on a lightweight Vantage alternative. Been an avid user of Legion Toolkit since the first release.

In v1.3.1, I can see Legion Toolkit is now responding to the FN+Q shortcut and setting the default Legion Power Plan for that Smart Fan Mode.

Since versions prior to v1.3.0 didn't provide this behaviour, I created a simple Powershell script which to achieve this.

Over time, I further customized the laptop behaviour:

Now that Legion Toolkit is also changing power plans on FN+Q, that conflicts with my custom scripts.

So I was thinking, since Legion Toolkit now runs in the background and is already listening to Lenovo WMI events, maybe a similar script-based event handling feature could be a useful addition for power users?

Benefits

  • A single background process (my Powershell process no longer required if Legion Toolkit is doing the event listening / handling)
  • Powerful behaviour customization, particularly if you intend to introduce a CLI

Proposed Behaviour

  1. On startup, listen for all Lenovo WMI events (LENOVO_GAMEZONE_SMART_FAN_MODE_EVENT, LENOVO_GAMEZONE_POWER_CHARGE_MODE_EVENT_EVENT, etc)
  2. When event is fired, locate all .bat, .ps1, .vbs, .bat, in a scripts folder adjacent to LegionToolkit.exe. Filter scripts to those which are prefixed with the event name.
  3. Run found scripts in serial in alphabetical order (to allow some control over execution order), passing the event info as an argument

The intention behind this approach is to make it easy for developers to distribute scripts which users can simply copy and paste to LegionToolkit folder.

For a working proof of concept, plase have a look at https://github.com/ldstein/legion-watcher:

  • lw.ps1 is the main process which listens for WMI events then locates and runs various scripts
  • scripts contains all the various event handlers
  • lws.p1 is a simple GUI which duplicates the Autostart / Vantage Service toggles of Legion Toolkit

If this sounds too out of scope, I'd like to suggest a menu option to disable Legion Toolkit's default FN+Q event handling. This would make it possible to override the default behaviour via third-party scripts/tools as described above.

Look forward to your thoughts!

@ldstein ldstein changed the title Script-based events [Suggestion] Script-based events Nov 25, 2021
@ldstein ldstein changed the title [Suggestion] Script-based events [Suggestion] Script-based event handling Nov 26, 2021
@BartoszCichecki BartoszCichecki added the feature New feature or request label Nov 26, 2021
@BartoszCichecki
Copy link
Owner

That is a great feature! I was thinking about adding some automation to this app, but wasn't sure if there is a need for that.

There are a couple of things before this can be done:

  1. Add some settings storage, so automation tasks can be maintained between app launches
  2. I need to figure out a way to switch refresh rate reliably

What I didn't know about is that there is a need to run custom scripts.

Definitely added to the list, but it will probably take some time (not gonna lie).

@ldstein
Copy link
Author

ldstein commented Dec 16, 2021

I just upgraded to 1.6.

Excellent work on the Power plan customization and Nvidia GPU deactivator. Greatly appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants