{"id":17693368,"url":"https://github.com/ttytm/dmon-zig","last_synced_at":"2025-05-13T03:17:46.197Z","repository":{"id":259095814,"uuid":"875343867","full_name":"ttytm/dmon-zig","owner":"ttytm","description":"Cross-platform Zig module to monitor changes in directories.","archived":false,"fork":false,"pushed_at":"2024-10-21T20:51:16.000Z","size":24,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-13T03:17:40.568Z","etag":null,"topics":["bindings","cross-platform","filesystem","library","linux","macos","monitor","monitoring","os","windows","zig","zig-package"],"latest_commit_sha":null,"homepage":"","language":"Zig","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ttytm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2024-10-19T18:12:33.000Z","updated_at":"2025-02-04T06:56:19.000Z","dependencies_parsed_at":"2024-10-23T02:36:27.826Z","dependency_job_id":null,"html_url":"https://github.com/ttytm/dmon-zig","commit_stats":null,"previous_names":["ttytm/dmon-zig"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ttytm%2Fdmon-zig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ttytm%2Fdmon-zig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ttytm%2Fdmon-zig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ttytm%2Fdmon-zig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ttytm","download_url":"https://codeload.github.com/ttytm/dmon-zig/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253863173,"owners_count":21975596,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["bindings","cross-platform","filesystem","library","linux","macos","monitor","monitoring","os","windows","zig","zig-package"],"created_at":"2024-10-24T13:44:50.487Z","updated_at":"2025-05-13T03:17:46.176Z","avatar_url":"https://github.com/ttytm.png","language":"Zig","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dmon-zig\n\n[badge__build-status]: https://img.shields.io/github/actions/workflow/status/ttytm/dmon-zig/ci.yml?branch=main\u0026logo=github\u0026logoColor=C0CAF5\u0026labelColor=333\n[badge__version-lib]: https://img.shields.io/github/v/tag/ttytm/dmon-zig?logo=task\u0026logoColor=C0CAF5\u0026labelColor=333\u0026color=\n[badge__version-zig]: https://img.shields.io/badge/Zig-0.13.0-cc742f?logo=zig\u0026logoColor=C0CAF5\u0026labelColor=333\n\n[![][badge__build-status]](https://github.com/ttytm/dmon-zig/actions?query=branch%3Amain)\n[![][badge__version-lib]](https://github.com/ttytm/dmon-zig/releases/latest)\n![][badge__version-zig]\n\nCross-platform Zig module to monitor changes in directories.\nIt utilizes the [dmon](https://github.com/septag/dmon?tab=readme-ov-file) C99 library.\n\n## Installation\n\n```sh\n# ~/\u003cProjectsPath\u003e/your-awesome-projct\nzig fetch --save https://github.com/ttytm/dmon-zig/archive/main.tar.gz\n```\n\n```zig\n// your-awesome-projct/build.zig\nconst std = @import(\"std\");\n\npub fn build(b: *std.Build) void {\n\t// ..\n\tconst dmon_dep = b.dependency(\"dmon\", .{});\n\tconst exe = b.addExecutable(.{\n\t\t.name = \"your-awesome-projct\",\n\t\t// ..\n\t});\n\texe.root_module.addImport(\"dmon\", dmon_dep.module(\"dmon\"));\n\t// ...\n}\n```\n\n## Usage Example\n\n```v\nconst std = @import(\"std\");\nconst dmon = @import(\"dmon\");\nconst print = std.debug.print;\n\nconst Context = struct {\n\ttrigger_count: u32 = 0,\n};\n\npub fn watchCb(\n\tcomptime Ctx: type,\n\t_: dmon.WatchId,\n\taction: dmon.Action,\n\troot_dir: [*:0]const u8,\n\tfile_path: [*:0]const u8,\n\told_file_path: ?[*:0]const u8,\n\tcontext: *Ctx,\n) void {\n\tprint(\"Action: {}\\n\", .{action});\n\tprint(\"Root: {s}\\n\", .{root_dir});\n\tprint(\"File path: {s}\\n\", .{file_path});\n\tprint(\"Old file path: {s}\\n\", .{old_file_path orelse \"\"});\n\tcontext.trigger_count += 1;\n}\n\npub fn main() !void {\n\tdmon.init();\n\tdefer dmon.deinit();\n\n\tconst watch_path = \"/home/user/Documents\";\n\tconst id = dmon.watch(Context, watch_path, watchCb, .{ .recursive = true }, \u0026ctx);\n\tprint(\"Starting to watch: {s}; Watcher ID: {d}\\n\", .{ watch_path, id });\n\n\twhile (true) {\n\t\tif (ctx.trigger_count \u003e= 3) break;\n\t}\n}\n```\n\nFor a simple local example watching the cwd: [`dmon-zig/examples/src/main.zig`](https://github.com/ttytm/dmon-zig/blob/main/examples/src/main.zig)\n\n```sh\n# Perform a lightweight, filtered, yet complete clone\ngit clone --recursive --shallow-submodules --filter=blob:none \\\n  https://github.com/ttytm/dmon-zig \u0026\u0026 \\\ncd dmon-zig/examples\n```\n\n```sh\n# dmon-zig/examples\nzig build run\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fttytm%2Fdmon-zig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fttytm%2Fdmon-zig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fttytm%2Fdmon-zig/lists"}