Properties

Properties is a string-to-string dictionary, the type used throughout WirePlumber for PipeWire object properties, event properties and so on. It binds the WpProperties C API.

Most of the time scripts obtain a Properties object from somewhere else — node.properties, Event.get_properties(), Conf.get_section_as_properties() — rather than constructing one.

Accessing values

Values are read and written with the normal Lua indexing syntax. Reading a key that is not set returns nil.

local props = node.properties

local name = props ["node.name"]
props ["my.custom.property"] = "value"

Because a Properties object holds strings, the typed accessors below are provided for the common cases of reading a value that represents a boolean or a number.

Properties(value)

Constructs a new Properties object.

Parameters:

value -- a Lua table of string keys and values to initialize from, or another Properties object to copy, or nothing for an empty object

Returns:

the new properties object

Return type:

Properties

Properties.get_boolean(self, key)

Returns the value of key interpreted as a boolean.

Parameters:

key (string) -- the key to look up

Returns:

the value, or nil if the key is not set

Return type:

boolean

Properties.get_int(self, key)

Returns the value of key interpreted as an integer.

Parameters:

key (string) -- the key to look up

Returns:

the value, or nil if the key is not set

Return type:

integer

Properties.get_float(self, key)

Returns the value of key interpreted as a floating point number.

Parameters:

key (string) -- the key to look up

Returns:

the value, or nil if the key is not set

Return type:

number

Properties.get_count(self)

Binds wp_properties_get_count()

Returns:

the number of properties in the object

Return type:

integer

Properties.copy(self)

Binds wp_properties_copy()

Returns an independent copy of the properties, which can be modified without affecting the original.

Returns:

a copy of the properties

Return type:

Properties

Properties.parse(self)

Converts the properties into a plain Lua table of string keys and values.

Note

This creates a full copy. Prefer indexing the Properties object directly when you only need a few keys; the shipped scripts were converted to do so because building a table for every object turned out to be measurably expensive.

Returns:

a table with the contents of the properties

Return type:

table