Waybar/resources/custom_modules/cffi_example
Adam Harvey 906170400e
cffi: always return config values as JSON
Previously, string JSON values were special cased to be provided as
bare strings, which means that CFFI modules have to either know what
type each value is expected to be, or use a heuristic such as trying to
decode and then treating the value as a string on failure.

Instead, we can always return JSON, and let the downstream consumer
handle deserialising the value into whatever type is expected.

The new behaviour is gated on a new ABI version 2: modules built against
version 1 will continue to get the old behaviour.
2025-03-05 17:11:26 -08:00
..
.gitignore Added cffi/* module for third-party advanced modules 2023-10-24 20:16:50 +02:00
README.md Send update dispatcher though FFI 2023-10-24 20:16:50 +02:00
main.c cffi: always return config values as JSON 2025-03-05 17:11:26 -08:00
meson.build Added cffi/* module for third-party advanced modules 2023-10-24 20:16:50 +02:00
waybar_cffi_module.h cffi: always return config values as JSON 2025-03-05 17:11:26 -08:00

README.md

C FFI module

A C FFI module is a dynamic library that exposes standard C functions and constants, that Waybar can load and execute to create custom advanced widgets.

Most language can implement the required functions and constants (C, C++, Rust, Go, Python, ...), meaning you can develop custom modules using your language of choice, as long as there's GTK bindings.

Symbols to implement are documented in the waybar_cffi_module.h file.

Usage

Building this module

meson setup build
meson compile -C build

Load the module

Edit your waybar config:

{
	// ...
	"modules-center": [
		// ...
		"cffi/c_example"
	],
	// ...
	"cffi/c_example": {
		// Path to the compiled dynamic library file
		"module_path": "resources/custom_modules/cffi_example/build/wb_cffi_example.so"
	}
}