Core
The WpCore API is mostly transparent to lua, as the core object is not exposed to the scripts.
For some functionality, though, the following static functions are exposed.
- Core.get_properties()
Binds
wp_connection_get_properties()Returns a table with the properties of the core. These are the same properties that appear on WirePlumber's client object in the PipeWire global registry.
- Returns:
the properties of the core
- Return type:
table
- Core.get_info()
Returns a table with information about the core. The table contains the following fields:
Field
Contains
cookie
The value of
wp_connection_get_remote_cookie()name
The value of
wp_connection_get_remote_name()user_name
The value of
wp_connection_get_remote_user_name()host_name
The value of
wp_connection_get_remote_host_name()version
The value of
wp_connection_get_remote_version()properties
The value of
wp_connection_get_remote_properties()- Returns:
information about the core
- Return type:
table
- Core.update_properties(properties)
Binds
wp_connection_update_properties()Updates the properties of the core, which are the properties that appear on WirePlumber's client object in the PipeWire global registry.
- Parameters:
properties -- a table or Properties object with the properties to set
- Core.get_own_bound_id()
Binds
wp_connection_get_own_bound_id()- Returns:
the global id of WirePlumber's own client object
- Return type:
integer
- Core.get_vm_type()
Binds
wp_context_get_vm_type()Detects whether WirePlumber is running inside a virtual machine. The ALSA monitor uses this to apply VM-specific workarounds.
- Returns:
the name of the virtual machine type, or nil if not running in a virtual machine
- Return type:
string
- Core.idle_add(callback)
Binds
wp_context_idle_add_closure()Schedules to call callback the next time that the event loop will be idle
- Parameters:
callback (function) -- the function to call; the function takes no arguments and must return true/false, as it is a GSourceFunc: return true to have the event loop call it again the next time it is idle, false to stop calling it and remove the associated GSource
- Returns:
the GSource associated with this idle callback
- Return type:
GSource, see
GSource.destroy()
- Core.timeout_add(timeout_ms, callback)
Binds
wp_context_timeout_add_closure()Schedules to call callback after timeout_ms milliseconds
- Parameters:
callback (function) -- the function to call; the function takes no arguments and must return true/false, as it is a GSourceFunc: return true to have the event loop call it again periodically every timeout_ms milliseconds, false to stop calling it and remove the associated GSource
- Returns:
the GSource associated with this idle callback
- Return type:
GSource, see
GSource.destroy()
- GSource.destroy(self)
For the purpose of working with
Core.idle_add()andCore.timeout_add(), the GSource object that is returned by those functions contains this method.Call this method to destroy the source, so that the associated callback is not called again. This can be used to stop a repeating timer callback or just to abort some idle operation
This method binds g_source_destroy
- Core.sync(callback)
Binds
wp_connection_sync()Calls callback after synchronizing the transaction state with PipeWire
- Parameters:
callback (function) -- a function to be called after syncing with PipeWire; the function takes an error string, if something went wrong and nil otherwise, and the sequence number of the sync operation, or nil if something went wrong; it returns nothing
- Returns:
the sequence number of the sync operation, or a negative errno if an error occurred before returning from this function
- Return type:
integer
- Core.quit()
Quits the current wpexec process
Note
This can only be called when the script is running in wpexec; if it is running in the main WirePlumber daemon, it will print a warning and do nothing
- Core.require_api(..., callback)
Ensures that the specified API plugins are loaded.
API plugins are plugins that provide some API extensions for use in scripts. These plugins must always have their name end in "-api" and the names specified here must not have the "-api" extension.
For instance, the "mixer-api" module provides an API to change volume/mute controls from scripts, via action signals. It can be used like this:
Core.require_api("mixer", function(mixer) -- get the volume of an audio stream local volume = mixer:call("get-volume", stream) -- the return value of "get-volume" is a GVariant(a{sv}), -- which gets translated to a Lua table Debug.dump_table(volume) end)
See also the example in
GObject.call()Note
This can only be called when the script is running in wpexec; if it is running in the main WirePlumber daemon, it will print a warning and do nothing
- Parameters:
... (strings) -- a list of string arguments, which specify the names of the api plugins to load, if they are not already loaded
callback -- the function to call after the plugins have been loaded; this function takes references to the plugins as parameters
- Core.test_feature()
Binds
wp_registry_test_feature()Tests if the specified feature is provided in the current WirePlumber configuration.
- Parameters:
feature (string) -- the name of the feature to test
- Returns:
true if the feature is provided, false otherwise
- Return type:
boolean
- Core.get_main_context()
Binds
wp_core_get_main_context()- Returns:
the main context of the core
- Return type:
- Core.get_connection()
Binds
wp_core_get_connection()- Returns:
the connection of the main context of the core
- Return type:
Context
The WpContext methods are available on the object
returned by Core.get_main_context():
- Context.get_core(self)
Binds
wp_context_get_core()- Returns:
the core of the context, or nil if that core is gone
- Context.get_spa_libs(self)
Binds
wp_context_get_spa_libs()- Returns:
the "context.spa-libs" description of the context, or nil
- Return type:
WpSpaJson
- Context.get_modules(self)
Binds
wp_context_get_modules()- Returns:
the "context.modules" description of the context, or nil
- Return type:
WpSpaJson
- Context.get_properties(self)
Binds
wp_context_get_properties()- Returns:
the properties of the context
- Return type:
- Context.get_vm_type(self)
Binds
wp_context_get_vm_type()- Returns:
a comma separated string with the virtual machine types that this context matches, or nil if not running in a virtual machine
- Return type:
string
- Context.idle_add(self, callback)
Binds
wp_context_idle_add_closure()The same as
Core.idle_add(), using this context.- Parameters:
callback (function) -- the function to call
- Returns:
the GSource associated with this idle callback
- Return type:
GSource, see
GSource.destroy()
- Context.timeout_add(self, timeout_ms, callback)
Binds
wp_context_timeout_add_closure()The same as
Core.timeout_add(), using this context.- Parameters:
timeout_ms (integer) -- the interval, in milliseconds
callback (function) -- the function to call
- Returns:
the GSource associated with this timeout callback
- Return type:
GSource, see
GSource.destroy()
MainContext
- MainContext.get_connection(self)
Binds
wp_main_context_get_connection()- Returns:
the connection of the context to PipeWire
- Return type:
Connection
The WpConnection object is returned by
MainContext.get_connection() and Core.get_connection().
- Connection.get_core(self)
Binds
wp_connection_get_core()- Returns:
the core that uses the connection, or nil if that core is gone
- Connection.get_own_bound_id(self)
Binds
wp_connection_get_own_bound_id()- Returns:
the global id of the client object of this connection
- Return type:
integer
- Connection.get_remote_cookie(self)
Binds
wp_connection_get_remote_cookie()- Returns:
the cookie of the PipeWire instance
- Return type:
integer
- Connection.get_remote_name(self)
Binds
wp_connection_get_remote_name()- Returns:
the name of the PipeWire instance
- Return type:
string
- Connection.get_remote_user_name(self)
Binds
wp_connection_get_remote_user_name()- Returns:
the name of the user that started the PipeWire instance
- Return type:
string
- Connection.get_remote_host_name(self)
Binds
wp_connection_get_remote_host_name()- Returns:
the name of the host where the PipeWire instance runs
- Return type:
string
- Connection.get_remote_version(self)
Binds
wp_connection_get_remote_version()- Returns:
the version of the PipeWire instance
- Return type:
string
- Connection.get_remote_properties(self)
Binds
wp_connection_get_remote_properties()- Returns:
the properties of the PipeWire instance
- Return type:
- Connection.get_properties(self)
Binds
wp_connection_get_properties()- Returns:
the properties of the connection
- Return type:
- Connection.update_properties(self, properties)
Binds
wp_connection_update_properties()- Parameters:
properties -- a table or Properties object with the properties to set
- Connection.sync(self, callback)
Binds
wp_connection_sync()Calls callback after synchronizing the transaction state with PipeWire
- Parameters:
callback (function) -- the same as in
Core.sync()- Returns:
the sequence number of the sync operation, or a negative errno if an error occurred before returning from this function
- Return type:
integer