2026-06-18 05:44:12 +00:00
|
|
|
# iZo
|
|
|
|
|
|
2026-06-18 19:27:05 -05:00
|
|
|
iZo is a small C++17 library that exposes common operating-system services through
|
|
|
|
|
one consistent API on Windows and Linux.
|
2026-06-18 00:49:32 -05:00
|
|
|
|
|
|
|
|
## Features
|
|
|
|
|
|
2026-06-18 21:00:51 -05:00
|
|
|
- Native open, save, folder, message, input, and color dialogs
|
2026-06-18 21:02:32 -05:00
|
|
|
- Command-line flags, values, integers, and positional arguments
|
2026-06-18 21:08:22 -05:00
|
|
|
- UTF-8 text, file-list, and RGBA image clipboard access
|
|
|
|
|
- Native desktop notifications
|
2026-06-18 19:27:05 -05:00
|
|
|
- Standard application, user, temporary, and executable paths
|
2026-06-18 21:16:23 -05:00
|
|
|
- Managed and blocking processes with pipes, timeouts, and output capture
|
2026-06-18 19:27:05 -05:00
|
|
|
- Move-only dynamic library handles with automatic cleanup
|
|
|
|
|
- Environment variables and basic system information
|
|
|
|
|
- Monotonic timing and sleeping
|
|
|
|
|
- Recursive or non-recursive directory watching
|
|
|
|
|
- Crash callbacks, debugger detection, debug breaks, and debug output
|
|
|
|
|
- Opening paths and revealing files in the platform file manager
|
2026-06-18 21:08:22 -05:00
|
|
|
- Battery status, sleep inhibition, shutdown, and restart controls
|
2026-06-18 00:49:32 -05:00
|
|
|
|
2026-06-18 19:27:05 -05:00
|
|
|
Linux dialogs discover `zenity` or `kdialog` at runtime. Linux clipboard access
|
2026-06-18 21:08:22 -05:00
|
|
|
discovers `wl-clipboard` or `xclip`; notifications use `notify-send`; sleep
|
|
|
|
|
inhibition uses `systemd-inhibit`. No GUI toolkit is linked into applications.
|
|
|
|
|
|
|
|
|
|
`Shutdown` and `Restart` request immediate system power actions and generally
|
|
|
|
|
require elevated operating-system privileges.
|
2026-06-18 00:49:32 -05:00
|
|
|
|
|
|
|
|
## Build
|
|
|
|
|
|
|
|
|
|
```sh
|
2026-06-18 19:27:05 -05:00
|
|
|
cmake -S . -B build -DIZO_BUILD_EXAMPLE=ON -DIZO_BUILD_TESTS=ON
|
2026-06-18 00:49:32 -05:00
|
|
|
cmake --build build
|
2026-06-18 19:27:05 -05:00
|
|
|
ctest --test-dir build
|
2026-06-18 00:49:32 -05:00
|
|
|
```
|
|
|
|
|
|
2026-06-18 19:32:43 -05:00
|
|
|
The unit test suite targets Linux and runs automatically on Gitea Actions using
|
|
|
|
|
an `ubuntu-latest` runner.
|
|
|
|
|
|
2026-06-18 00:49:32 -05:00
|
|
|
To consume an installed copy:
|
|
|
|
|
|
|
|
|
|
```cmake
|
|
|
|
|
find_package(iZo CONFIG REQUIRED)
|
|
|
|
|
target_link_libraries(your_target PRIVATE iZo::izo)
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
2026-06-18 19:27:05 -05:00
|
|
|
Include individual feature headers or the complete API:
|
|
|
|
|
|
2026-06-18 00:49:32 -05:00
|
|
|
```cpp
|
2026-06-18 19:40:23 -05:00
|
|
|
#include <izo/iZo.hpp>
|
2026-06-18 00:49:32 -05:00
|
|
|
|
2026-06-18 21:02:32 -05:00
|
|
|
izo::CommandLine args(argc, argv);
|
|
|
|
|
if (args.Has("--verbose")) {
|
|
|
|
|
// Enable verbose logging.
|
|
|
|
|
}
|
|
|
|
|
const auto configPath = args.Get("--config");
|
|
|
|
|
const int threads = args.GetInt("--threads", 4);
|
|
|
|
|
|
2026-06-18 21:08:22 -05:00
|
|
|
izo::ShowNotification("Build complete", "iZo finished compiling");
|
|
|
|
|
|
|
|
|
|
izo::ClipboardImage image{2, 1, {
|
|
|
|
|
255, 0, 0, 255,
|
|
|
|
|
0, 0, 255, 255,
|
|
|
|
|
}};
|
|
|
|
|
izo::SetClipboardImage(image);
|
|
|
|
|
|
|
|
|
|
if (izo::PreventSleep()) {
|
|
|
|
|
// Run a render job, then release the operating-system sleep inhibitor.
|
|
|
|
|
izo::AllowSleep();
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-18 19:40:23 -05:00
|
|
|
izo::DialogOptions options;
|
2026-06-18 00:49:32 -05:00
|
|
|
options.title = "Choose an image";
|
|
|
|
|
options.filters = {{"Images", {"*.png", "*.jpg"}}};
|
|
|
|
|
|
2026-06-18 19:40:23 -05:00
|
|
|
if (auto selection = izo::OpenFile(options)) {
|
|
|
|
|
izo::RevealInFileManager(selection.paths.front());
|
2026-06-18 19:27:05 -05:00
|
|
|
}
|
|
|
|
|
|
2026-06-18 21:00:51 -05:00
|
|
|
if (izo::ShowQuestionBox("Delete file?", "This cannot be undone.") ==
|
|
|
|
|
izo::MessageResponse::Yes) {
|
|
|
|
|
// Delete it.
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (auto name = izo::ShowInputBox({"Profile", "Display name:"})) {
|
|
|
|
|
// name.value contains the submitted UTF-8 text.
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (auto color = izo::PickColor({"Accent color", {32, 128, 255}})) {
|
|
|
|
|
// color.color contains the selected RGB channels.
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-18 19:40:23 -05:00
|
|
|
auto config = izo::GetKnownPath(izo::KnownPath::Config);
|
2026-06-18 19:27:05 -05:00
|
|
|
|
2026-06-18 19:40:23 -05:00
|
|
|
izo::ProcessOptions process;
|
2026-06-18 19:27:05 -05:00
|
|
|
process.executable = "tool";
|
|
|
|
|
process.arguments = {"--input", "asset.png"};
|
2026-06-18 21:16:23 -05:00
|
|
|
process.captureOutput = true;
|
|
|
|
|
process.timeoutMs = 5000;
|
|
|
|
|
const auto completed = izo::RunProcess(process);
|
|
|
|
|
if (completed.exitCode == 0) {
|
|
|
|
|
// completed.stdoutText contains the tool output.
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
process.pipeStdin = true;
|
|
|
|
|
if (auto running = izo::StartProcess(process)) {
|
|
|
|
|
running.WriteStdin("input");
|
|
|
|
|
running.CloseStdin();
|
|
|
|
|
running.Wait();
|
2026-06-18 00:49:32 -05:00
|
|
|
}
|
|
|
|
|
```
|
2026-06-18 19:27:05 -05:00
|
|
|
|
|
|
|
|
Resource-owning APIs are move-only and clean themselves up:
|
|
|
|
|
|
|
|
|
|
```cpp
|
|
|
|
|
std::string error;
|
2026-06-18 19:40:23 -05:00
|
|
|
auto library = izo::LoadDynamicLibrary("plugin.dll", &error);
|
2026-06-18 19:27:05 -05:00
|
|
|
if (library) {
|
2026-06-18 19:40:23 -05:00
|
|
|
void* entry = library.Symbol("initialize_plugin", &error);
|
2026-06-18 19:27:05 -05:00
|
|
|
}
|
|
|
|
|
|
2026-06-18 19:40:23 -05:00
|
|
|
auto watcher = izo::WatchDirectory(
|
2026-06-18 19:27:05 -05:00
|
|
|
{{"assets"}, true},
|
2026-06-18 19:40:23 -05:00
|
|
|
[](const izo::FileEvent& event) {
|
2026-06-18 19:27:39 -05:00
|
|
|
// Handle added, removed, modified, or renamed files.
|
2026-06-18 19:40:23 -05:00
|
|
|
// Rename events provide the old path in event.previousPath.
|
2026-06-18 19:27:05 -05:00
|
|
|
},
|
|
|
|
|
&error);
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Dialog calls block until dismissed. Directory callbacks run on the watcher's worker
|
|
|
|
|
thread and must not destroy their own watcher.
|