2.2.1 Example Configuration: Modules
At the top of our configuration, we see this:
(use-modules (librekontrol core)
(librekontrol device)
(librekontrol input)
(librekontrol alsa)
((librekontrol devices ni-ak1) #:prefix ak1:))
Guile, the programming language in which Librekontrol configuration is
done, has a module system. This allows you to only load the modules
that you need to do your particular configuration (or, potentially,
for others to share convenient Librekontrol code with others).
Here, we are loading several Librekontrol modules:
- ‘(librekontrol core)’ contains important low-level functions for opening
and manipulating devices. This will almost always need to be used.
- ‘(librekontrol device)’ contains most of the high-level configuration
functions. Unless you’re relying on only the low-level programming
interface, you’ll almost always need to use this module.
- ‘(librekontrol input)’ contains definitions related to input
events. If you’re planning to map functions to device events (which
is the main usage of Librekontrol), you will need to use this module.
- ‘(librekontrol alsa)’ contains definitions related to ALSA
hardware controls, which are typically LEDs on the device. Usually
these are controlled via the high-level functions in
‘(librekontrol device)’. If you want to manipulate these LEDs
directly, though, you might want to use this module. We will be doing
that here.
- ‘(librekontrol devices ni-ak1)’ contains definitions specific to
the AK1 device, which we need to be able to map functions to the
device’s controls. You’ll notice that the structure of this module’s
statement is slightly different in that it includes ‘#:prefix
ak1:’ together with the module name, all in another layer of
parentheses. This makes any symbols loaded from the module be
prefixed with ‘ak1:’ (e.g. ‘alsa-name’ becomes
‘ak1:alsa-name’) This isn’t strictly necessary in this example,
however if you will be configuring multiple devices, it might be a
good idea. This helps to avoid problems if similar symbols are
defined for two devices. If both devices define a control called
‘volume’, then you need a way to distinguish between them.