Firzen's Logitech G19 Scripts


Download Core

The core contains two modules. The ScriptManager and the EventManager.


The ScriptManager is for loading scripts from the core directory.
This is no primitive task as the core directory probably differs from the execution directory.

ScriptManager.loadScript(fileName) will load the script with the given filename, whereas the file path is considered to be relative to the core script directory.
The function passes the loaded script's directory as first program argument so it may load additional files from there.
Initially this was also planned to enable a script reading and writing files from and to it's directory, but unfortunately the Logitech G19 script environment disables io and os functions. dofile and loadfile work nevertheless though.


The Logitech G19 script API provides one function to handle incoming events like a pressed G key. The EventManager can be used to add an arbitrary amount of handler functions for specific or general events.

EventManager.addEventHandler(event, argument, handler) will add a new event handler function to the existing pool.
event specifies the event's name, e.g. 'G_KEY_PRESSED', argument sets a filter for the argument provided with the event, e.g. 7 in combination with the mentioned event example to set a handler for the G7 key, and the last argument, handler is the actual handler function.
If all arguments are specified, the given handler will only be called, if the incoming event matches the constraints. argument may be left out to make a handler for the named event, regardless of the respective attribute. In addition, event may be left out as well to create a handler like the OnEvent function itself.
Any event triggering OnEvent will cause the EventHandler to invoke all handler functions assigned to the event, passing the event's name as first and the argument as second argument.

That said, an existing OnEvent function may easily be made compatible to the core scripts by renaming it, e.g. to GlobalEventHandler, and adding it as global event handler. For the mentioned example this could be done by calling EventManager.addEventHandler(GlobalEventHandler).


Random Color Fader

Download Color Fader (requires the Core)

The color fader script binds (up to) three keys.
One key for enabling and displaying information, if the script is already enabled, one key for disabling and one for fading to the next random color.

What the script basically does is fading your backlight from one color to another, whereas the new color is chosen randomly.
The script also fades in on loading the profile and out on unloading it. It preserves the backlight color when changing the mode and also when switching it off and on.
Due to a lack of I/O functionality in the Logitech G19 script environment the script is unable to save and load colors between different profiles.

If you happen to get a backlight color you really like you can find out the color code by pressing the enable key while the color script is enabled. The color information will be displayed on your display then. If it doesn't work right away, give it some further tries. The display sometimes doesn't want to react.