{"id":17272339,"url":"https://github.com/pmanot/battery","last_synced_at":"2026-03-09T02:32:07.090Z","repository":{"id":252691021,"uuid":"619549743","full_name":"pmanot/Battery","owner":"pmanot","description":"A lightweight multi-platform framework for accessing battery info","archived":false,"fork":false,"pushed_at":"2024-08-11T19:31:13.000Z","size":24,"stargazers_count":10,"open_issues_count":1,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-14T08:42:43.947Z","etag":null,"topics":["battery","battery-info","battery-information","battery-level","battery-monitor","battery-percentage","combine-framework","reactive-programming","state","swift"],"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/pmanot.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":"2023-03-27T11:11:29.000Z","updated_at":"2025-03-02T09:38:27.000Z","dependencies_parsed_at":"2024-08-11T20:54:13.446Z","dependency_job_id":null,"html_url":"https://github.com/pmanot/Battery","commit_stats":null,"previous_names":["pmanot/battery"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pmanot/Battery","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmanot%2FBattery","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmanot%2FBattery/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmanot%2FBattery/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmanot%2FBattery/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pmanot","download_url":"https://codeload.github.com/pmanot/Battery/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmanot%2FBattery/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30280852,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-09T02:23:26.802Z","status":"ssl_error","status_checked_at":"2026-03-09T02:22:46.175Z","response_time":61,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["battery","battery-info","battery-information","battery-level","battery-monitor","battery-percentage","combine-framework","reactive-programming","state","swift"],"created_at":"2024-10-15T08:48:25.658Z","updated_at":"2026-03-09T02:32:07.052Z","avatar_url":"https://github.com/pmanot.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Battery\n\nA lightweight multi-platform framework for accessing battery info\n\n## Features\n* Get battery percentage, charging state, low power mode state\n* Observe battery changes through published properties\n* Multi-platform support\n\n## Installation\nYou can add the Battery framework to your project via Swift Package Manager. \nSimply go to File \u003e Swift Packages \u003e Add Package Dependency and enter the following URL: https://github.com/pmanot/Battery.\n\n## Usage\nTo use Battery, first, import the module: \n\n```\nimport Battery\n```\n\nThen, create an instance of the Battery class: \n\n```\nlet battery = Battery()\n```\n\n```\nvar cancellables: [AnyCancellable] = []\n\nbattery.$percentage.sink { percentage in\n    print(\"Battery percentage: \\(percentage)\")\n}\n.store(in: \u0026cancellables)\n\nbattery.$state.sink { state in\n    print(\"Battery state: \\(state)\")\n}\n.store(in: \u0026cancellables)\n\nbattery.$isLowPowerModeEnabled.sink { isEnabled in\n    print(\"Low power mode enabled: \\(isEnabled)\")\n}\n.store(in: \u0026cancellables)\n```\n\n## API\n### `Battery` \nThe main class of the framework. Provides the following properties: \n\n- `percentage`: The battery percentage as an integer (0-100) \n- `state`: The current state of the battery (BatteryState) \n- `isLowPowerModeEnabled`: A boolean indicating whether low power mode is enabled or not  \n\n### `BatteryState` \nAn enum representing the state of the battery. It has the following cases:  \n \n- `charging`: The battery is currently charging \n- `discharging`: The battery is discharging \n- `chargedAndPlugged`: The battery is fully charged and plugged in \n- `unknown`: The battery state is unknown \n\n### `PowerSource` \nAn enum representing the power source. It has the following cases: \n\n- `powerAdapter`: The battery is connected to a power adapter \n- `battery`: The battery is running on its own power\n- `unknown`: The power source is unknown  \n\n## License\nBattery is available under the MIT license. See the LICENSE file for more info.\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpmanot%2Fbattery","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpmanot%2Fbattery","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpmanot%2Fbattery/lists"}