2 releases
new 0.1.1 | Mar 6, 2025 |
---|---|
0.1.0 | Mar 6, 2025 |
#849 in GUI
38 downloads per month
Used in 2 crates
(via waybar-cffi)
13KB
192 lines
waybar-cffi
This provides Rust bindings to create CFFI modules for Waybar.
Waybar CFFI modules are shared libraries that provide modules that can be included in a Waybar. These can use the full capabilities of Gtk 3 and, more generally, native code.
Quick start
Creating and using a CFFI module is (relatively) easy.
-
Create a
cdylib
crate:[package] name = "my-module-name" version = "0.1.0" edition = "2024" [lib] crate-type = ["cdylib"] [dependencies] waybar-cffi = "0.1.0"
-
Implement the
waybar_cffi::Module
trait on a type, and use thewaybar_cffi::waybar_module
macro to export the required symbols. (See the hello world example or the documentation for more detail.) -
Build in the normal way with
cargo build
. -
Configure
waybar
per the CFFI instructions:{ "modules-left": ["cffi/my-module-name"], "cffi/my-module-name": { "module-path": "target/debug/libmy_module_name.so" } }
-
Profit!
Refer to the waybar-cffi
documentation for more details.
Development
Honestly, I probably won't be devoting a tonne of time to this in the near future, but I'm definitely open to PRs.
Layout
This workspace contains two crates:
waybar-cffi
: the main entry point into the CFFI functionality.waybar-cffi-sys
: the low level bindings based on the CFFI header.
Updating bindings
New Waybar versions will likely require the bindings to be updated. This can be
done by running make clean && make ffi WAYBAR_ROOT=path/to/Waybar
.
Note that a full Waybar checkout is currently required as the CFFI header isn't shipped in the release packages.
Smoke tests
make hello-world
will build the hello world
example and run Waybar with two instances
of it configured.
Dependencies
~17MB
~413K SLoC