Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ziqi-yang/greetd_ipc

[mirror] Zig library for interacting with [greetd](https://sr.ht/~kennylevinsen/greetd/) ipc.
https://github.com/ziqi-yang/greetd_ipc

greetd ipc zig

Last synced: 4 days ago
JSON representation

[mirror] Zig library for interacting with [greetd](https://sr.ht/~kennylevinsen/greetd/) ipc.

Awesome Lists containing this project

README

        

# Greetd_IPC

## Installation

Supported Zig Version: `0.13`.

``` bash
zig fetch 'https://codeberg.org/meow_king/greetd_ipc/archive/v0.1.1.tar.gz' --save
```

Then you can add this dependency into `build.zig` file:

``` zig
const dep = b.dependency("greetd_ipc", .{ .target = target, .optimize = optimize });
const module = dep.module("greetd_ipc");
exe.root_module.addImport("greetd_ipc", module);
```

For other version of Zig, you can include `greetd-ipc.zig` file into
your source directory.

## Usage

``` zig
const std = @import("std");

pub fn main() !void {
var gpa_impl = std.heap.GeneralPurposeAllocator(.{}){};
defer if (gpa_impl.deinit() == .leak) @panic("MEMORY LEAK");
const gpa = gpa_impl.allocator();

const gipc: GreetdIPC = try GreetdIPC.new(null, gpa);
defer gipc.deinit();
const request: Request = .{ .create_session = .{ .username = "user"}};
try gipc.sendMsg(request);
const response = try gipc.readMsg();
std.debug.print("{s}\n", .{std.json.fmt(response, .{})});
}
```

## Run Example

Build `fakegreet` from [greetd](https://git.sr.ht/~kennylevinsen/greetd)
repo.

``` bash
zig build -Dexample=examples/demo.zig run-example
fakegreet ./zig-out/bin/demo
```

Or you can run the following command if you have
[just](https://github.com/casey/just) installed.

``` bash
just run
```

Note `fakegreet` is a testing tool inside greetd's repo. see
[source](https://git.sr.ht/~kennylevinsen/greetd/tree/master/item/fakegreet/src/main.rs).