{"id":50531871,"url":"https://github.com/weskoerber/swayipc","last_synced_at":"2026-06-03T14:30:29.742Z","repository":{"id":336614772,"uuid":"1150317253","full_name":"weskoerber/swayipc","owner":"weskoerber","description":"[Mirror] A Sway IPC client implementation.","archived":false,"fork":false,"pushed_at":"2026-02-05T08:42:24.000Z","size":26,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-02-05T20:10:38.344Z","etag":null,"topics":["ipc","sway","swaywm","zig","zig-package"],"latest_commit_sha":null,"homepage":"https://codeberg.org/weskoerber/swayipc","language":"Zig","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/weskoerber.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-02-05T06:11:10.000Z","updated_at":"2026-02-05T08:42:27.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/weskoerber/swayipc","commit_stats":null,"previous_names":["weskoerber/swayipc"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/weskoerber/swayipc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weskoerber%2Fswayipc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weskoerber%2Fswayipc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weskoerber%2Fswayipc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weskoerber%2Fswayipc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/weskoerber","download_url":"https://codeload.github.com/weskoerber/swayipc/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weskoerber%2Fswayipc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33870025,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-03T02:00:06.370Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ipc","sway","swaywm","zig","zig-package"],"created_at":"2026-06-03T14:30:27.101Z","updated_at":"2026-06-03T14:30:29.730Z","avatar_url":"https://github.com/weskoerber.png","language":"Zig","funding_links":[],"categories":[],"sub_categories":[],"readme":"# swayipc\n\nA Sway IPC client implementation.\n\n## Usage\n\n```zig\nconst std = @import(\"std\");\nconst swayipc = @import(\"swayipc\");\nconst IpcConnection = swayipc.IpcConnection;\n\npub fn main(init: std.process.Init) !void {\n    // 1. Connect to the socket at $SWAYSOCK.\n    const ipc_stream = try swayipc.connect(.{ .env = init.environ_map }, init.io);\n    defer ipc_stream.close(init.io);\n\n    // 2. Create a socket reader and writer.\n    var ipc_read_buf: [1024]u8 = undefined;\n    var ipc_write_buf: [1024]u8 = undefined;\n    var ipc_reader = ipc_stream.reader(init.io, \u0026ipc_read_buf);\n    var ipc_writer = ipc_stream.writer(init.io, \u0026ipc_write_buf);\n\n    // 3. Initialize the connection wrapper.\n    var ipc = IpcConnection.init(\u0026ipc_reader.interface, \u0026ipc_writer.interface);\n\n    // 4. Send IPC messages.\n    const version = try ipc.getVersion(init.gpa);\n    defer version.deinit();\n    std.debug.print(\"sway version: {s}\\n\", .{version.value.human_readable});\n\n    // 5. Subscribe to events.\n    // 5a. Define events to subscribe.\n    const events: []const swayipc.Event = \u0026.{ .workspace, .tick };\n\n    // 5b. Define event handlers.\n    const handlers: IpcConnection.EventHandlers = .{\n        .default = handleEvent,\n        .tick = handleTickEvent,\n    };\n\n    // 5c. Send the subscribe IPC message.\n    try ipc.subscribe(init.gpa, events, handlers);\n}\n\nfn handleEvent(gpa: std.mem.Allocator, event: swayipc.Event, body: []const u8) bool {\n    _ = gpa;\n    _ = body;\n\n    std.log.warn(\"unhandled event: '{t}'\", .{event});\n\n    return true;\n}\n\nfn handleTickEvent(tick: swayipc.events.Tick) bool {\n    return !std.mem.eql(u8, tick.payload, \"HUP\");\n}\n```\n\n## Run the example\n\nRun the provided example to demonstrate basic capabilities:\n\n```shell\nzig build run\n```\n\nThis will print out sway's version then subscribe to the `workspace` and `tick`\nevent.\n\nIf the payload of a `tick` event is `HUP`, the events are unsubscribed and the\nprogram terminates. To send `HUP` in a tick event, use `swaymsg`:\n\n```shell\nswaymsg -t send_tick HUP\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweskoerber%2Fswayipc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fweskoerber%2Fswayipc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweskoerber%2Fswayipc/lists"}