| 1 |
.. _scripting_custom_scripts: |
| 2 |
|
| 3 |
Custom Scripts |
| 4 |
============== |
| 5 |
|
| 6 |
The locations where WirePlumber searches for scripts is explained in |
| 7 |
:ref:`config_locations_scripts`. |
| 8 |
|
| 9 |
Scripts are not loaded automatically; a component muse be defined for them, and |
| 10 |
this component must be included in a profile. See |
| 11 |
:ref:`config_components_and_profiles`. |
| 12 |
|
| 13 |
Full example |
| 14 |
------------ |
| 15 |
|
| 16 |
Let's assume that ``~/.local/share/wireplumber/scripts/90-hello-world.lua`` |
| 17 |
contains the following script: |
| 18 |
|
| 19 |
.. code-block:: lua |
| 20 |
|
| 21 |
log = Log.open_topic("hello-world") |
| 22 |
log.info("Hello world") |
| 23 |
|
| 24 |
In order for it to run, we'll define a component and include it in the default |
| 25 |
profile by including the following configuration (for example, in |
| 26 |
``~/.config/wireplumber/wireplumber.conf.d/90-hello-world.conf``): |
| 27 |
|
| 28 |
.. code-block:: |
| 29 |
|
| 30 |
wireplumber.components = [ |
| 31 |
{ |
| 32 |
name = "90-hello-world.lua", type = script/lua |
| 33 |
provides = hello-world |
| 34 |
} |
| 35 |
] |
| 36 |
|
| 37 |
wireplumber.profiles = { |
| 38 |
main = { |
| 39 |
hello-world = required |
| 40 |
} |
| 41 |
} |