Skip to content

Latest commit

 

History

History
59 lines (43 loc) · 1.46 KB

README.md

File metadata and controls

59 lines (43 loc) · 1.46 KB

Greetd_IPC

Installation

Supported Zig Version: 0.13.

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:

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

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 repo.

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

Or you can run the following command if you have just installed.

just run

Note fakegreet is a testing tool inside greetd's repo. see source.