Rust bindings for nativeapi — unified access to native system APIs: windows, tray icons, menus, displays, keyboard, dialogs, storage and more.
| Linux | macOS | Windows |
|---|---|---|
| ✅ | ✅ | ✅ |
🚧 Work in Progress: this crate is under active development.
cargo add nativeapiBuilding requires CMake and a C++17 compiler (the core library is compiled by build.rs). On Linux, also install:
sudo apt install libgtk-3-dev libx11-dev libxi-devThe crate is split into nativeapi (safe API) and cnativeapi (raw FFI).
use nativeapi::DisplayManager;
fn main() {
for display in DisplayManager::get_all() {
let size = display.size();
println!("{}: {}x{}", display.name().unwrap_or_default(), size.width, size.height);
}
}The examples are the rust_* directories in the repository's examples/, members of the cargo workspace at the repository root. Each is a crate covering one module:
cargo run -p display_example
cargo run -p window_example
cargo run -p tray_icon_exampleshortcut_example and keyboard_example need accessibility permission on macOS — run accessibility_example first.
nativeapi_gpui integrates nativeapi with GPUI: the nativeapi Window behind a GPUI window, event delivery to GPUI entities, geometry and color conversions, and DragToMoveArea / DragToResizeArea elements. The gpui_* directories in examples/ are built on it; each is its own cargo workspace (cd examples/gpui_window_example && cargo run).
Development happens in nativeapi, which holds every binding and the code generator and checks out the core library as a submodule:
git clone --recursive https://github.com/libnativeapi/nativeapi.gitFiles marked AUTO-GENERATED. DO NOT EDIT. are generated from the C++ headers in nativeapi. To change the API, send a pull request there; maintainers regenerate the bindings.
- API requests and native behavior bugs → nativeapi-core issues
- Bugs specific to one binding → nativeapi issues
- Not sure → nativeapi-core issues
MIT