Next: Example Config Exit Hooks, Previous: Example Config Controls, Up: Tutorial [Contents][Index]
The next option is #:init.
(configure-device ... #:init (list (lambda () (turn-off-ctls (map control-alsa-ctl (list ak1:left ak1:middle ak1:right ak1:knob))))) ...)
This option lets you perform whatever additional initialization of the device you would like to do. It takes as its argument a list of procedures to be run at configuration time. Each procedure is defined using lambda and takes no arguments.
In this example, we define a procedure that turns off all the LEDs. Sometimes, especially if you’re playing around with a configuration and you mess up something, you might end up exiting Librekontrol with some LEDs still on. This procedure returns the device to a clean state.
First, the ALSA hardware-control handle (called a ctl throughout Librekontrol, which tells the program how to find the LED) for each control is retrieved by mapping the control-alsa-ctl procedure onto a list of all the AK1 controls. The resulting list of ctls is then passed to the turn-off-ctls procedure.