{"id":15561249,"url":"https://github.com/p-x9/swift-sysctl","last_synced_at":"2025-12-28T03:31:36.666Z","repository":{"id":233607906,"uuid":"786470090","full_name":"p-x9/swift-sysctl","owner":"p-x9","description":"A Swift wrapper for sysctl.","archived":false,"fork":false,"pushed_at":"2024-04-26T05:00:50.000Z","size":219,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-05-09T11:19:04.938Z","etag":null,"topics":["swift","sysctl"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/p-x9.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-04-14T15:06:12.000Z","updated_at":"2024-05-15T18:42:23.552Z","dependencies_parsed_at":"2024-05-15T18:42:21.358Z","dependency_job_id":"180b951f-641d-4415-a266-02e030555c16","html_url":"https://github.com/p-x9/swift-sysctl","commit_stats":null,"previous_names":["p-x9/swift-sysctl"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p-x9%2Fswift-sysctl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p-x9%2Fswift-sysctl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p-x9%2Fswift-sysctl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p-x9%2Fswift-sysctl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/p-x9","download_url":"https://codeload.github.com/p-x9/swift-sysctl/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250525305,"owners_count":21445042,"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":["swift","sysctl"],"created_at":"2024-10-02T16:06:45.592Z","updated_at":"2025-12-28T03:31:36.600Z","avatar_url":"https://github.com/p-x9.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# swift-sysctl\n\nA Swift wrapper for `sysctl`.\n\n\u003c!-- # Badges --\u003e\n\n[![Github issues](https://img.shields.io/github/issues/p-x9/swift-sysctl)](https://github.com/p-x9/swift-sysctl/issues)\n[![Github forks](https://img.shields.io/github/forks/p-x9/swift-sysctl)](https://github.com/p-x9/swift-sysctl/network/members)\n[![Github stars](https://img.shields.io/github/stars/p-x9/swift-sysctl)](https://github.com/p-x9/swift-sysctl/stargazers)\n[![Github top language](https://img.shields.io/github/languages/top/p-x9/swift-sysctl)](https://github.com/p-x9/swift-sysctl/)\n\n## Usage\n\nThe basic functions are defined in the Sysctl namespace.\n\n### Access\n\nYou can access specific values in the same way as for an oid name, in a chain of name, as follows:\n\n```swift\n// \"kern.osversion\"\nlet osVersion = Sysctl.sysctl(kern.osversion)\n\n// \"machdep.cpu.vendor\"\nlet cpuVendorName = Sysctl.sysctl(machdep.cpu.vendor)\n```\n\nEach field also holds the type information of the value associated with its OID.\nTherefore, in the above example, the value is automatically obtained as a String.\n\n(See [Node directory](./Sources/SwiftSysctl/Node/))\n\n\u003e [!NOTE]\n\u003e Some values cannot be read without root permission.\n\n\u003e [!NOTE]\n\u003e OIDs that exist vary greatly depending on the CPU architecture.\n\u003e Some OIDs may not exist except on macOS.\n\n## Implementation\n\nThe following is a brief description of the implementation.\n\n### OID\n\nIn the [OID directory](./Sources/SwiftSysctl/OID/), the name, id, and value type information of the OID for each node are defined.\n\n### Node\n\nThe OIDs provided to sysctl are structured as a tree.\nEach node in the tree is defined in the [Node directory](./Sources/SwiftSysctl/Node/).\n\nIf a node has children, the aggregate type of the child nodes is retained as Node\\\u003cChild\\\u003e type.\n\n```swift\npublic let ipc = Node\u003cIpc\u003e(\n    oid: OID.Kern.ipc\n)\n```\n\nIf it is a terminal node, it has type information for the value associated with the OID.\n\n```swift\npublic let ostype = LeafNode\u003cString\u003e(\n    oid: OID.Kern.ostype\n)\n```\n\n### Field\n\nField is the path traced from the root node to the terminal node.\n(The root node is defined in [TopNodes.swift](./Sources/SwiftSysctl/TopNodes.swift).)\n\nFrom the root node to the terminal node, it is possible to access the nodes by dot-connecting.\n\n```swift\nlet field: Field\u003cString\u003e = kern.ostype\nlet field2: Field\u003cCInt\u003e = kern.argmax\n```\n\nThe value can be retrieved by giving this `Field` to the `Sysctl.sysctl` function.\n\n```swift\nlet ostype: String = Sysctl.sysctl(field)\nlet argmax: CInt = Sysctl.sysctl(field)\n```\n\n## License\n\nswift-sysctl is released under the MIT License. See [LICENSE](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fp-x9%2Fswift-sysctl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fp-x9%2Fswift-sysctl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fp-x9%2Fswift-sysctl/lists"}