Skip to content

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

License

Notifications You must be signed in to change notification settings

Ziqi-Yang/greetd_ipc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Greetd_IPC

Project page
API Documentation

Installation

For zig master branch, run the following command

zig fetch 'https://git.sr.ht/~meow_king/greetd_ipc/archive/v0.1.0.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.