{"id":13413485,"url":"https://github.com/distatus/battery","last_synced_at":"2026-01-28T18:39:19.091Z","repository":{"id":44961457,"uuid":"53757596","full_name":"distatus/battery","owner":"distatus","description":"cross-platform, normalized battery information library","archived":false,"fork":false,"pushed_at":"2023-09-27T07:39:30.000Z","size":80,"stargazers_count":244,"open_issues_count":6,"forks_count":36,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-07-31T20:52:23.190Z","etag":null,"topics":["battery","cross-platform","go"],"latest_commit_sha":null,"homepage":"","language":"Go","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/distatus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null},"funding":{"github":"KenjiTakahashi"}},"created_at":"2016-03-12T23:03:40.000Z","updated_at":"2024-07-19T20:07:35.000Z","dependencies_parsed_at":"2022-09-11T15:03:05.268Z","dependency_job_id":"77ae977d-a944-4039-967e-1920b8e8a064","html_url":"https://github.com/distatus/battery","commit_stats":{"total_commits":76,"total_committers":8,"mean_commits":9.5,"dds":0.09210526315789469,"last_synced_commit":"24c526632a1ddc76871394d63705ebe668dab97c"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/distatus%2Fbattery","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/distatus%2Fbattery/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/distatus%2Fbattery/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/distatus%2Fbattery/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/distatus","download_url":"https://codeload.github.com/distatus/battery/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243635470,"owners_count":20322945,"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":["battery","cross-platform","go"],"created_at":"2024-07-30T20:01:41.449Z","updated_at":"2026-01-28T18:39:14.063Z","avatar_url":"https://github.com/distatus.png","language":"Go","readme":"battery [![Build Status](https://github.com/distatus/battery/actions/workflows/tests.yml/badge.svg?branch=master)](https://github.com/distatus/battery/actions/workflows/tests.yml) [![Go Report Card](https://goreportcard.com/badge/github.com/distatus/battery)](https://goreportcard.com/report/github.com/distatus/battery) [![GoDoc](https://pkg.go.dev/badge/github.com/distatus/battery)](https://pkg.go.dev/github.com/distatus/battery)\n=======\n\nCross-platform, normalized battery information library.\n\nGives access to a system independent, typed battery state, capacity, charge and voltage values recalculated as necessary to be returned in mW, mWh or V units.\n\nCurrently supported systems:\n\n* Linux 2.6.39+\n* OS X 10.10+\n* Windows XP+\n* FreeBSD\n* DragonFlyBSD\n* NetBSD\n* OpenBSD\n* Solaris\n\nInstallation\n------------\n\n```bash\n$ go get -u github.com/distatus/battery\n```\n\nCode Example\n------------\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/distatus/battery\"\n)\n\nfunc main() {\n\tbatteries, err := battery.GetAll()\n\tif err != nil {\n\t\tfmt.Println(\"Could not get battery info!\")\n\t\treturn\n\t}\n\tfor i, battery := range batteries {\n\t\tfmt.Printf(\"Bat%d: \", i)\n\t\tfmt.Printf(\"state: %s, \", battery.State.String())\n\t\tfmt.Printf(\"current capacity: %f mWh, \", battery.Current)\n\t\tfmt.Printf(\"last full capacity: %f mWh, \", battery.Full)\n\t\tfmt.Printf(\"design capacity: %f mWh, \", battery.Design)\n\t\tfmt.Printf(\"charge rate: %f mW, \", battery.ChargeRate)\n\t\tfmt.Printf(\"voltage: %f V, \", battery.Voltage)\n\t\tfmt.Printf(\"design voltage: %f V\\n\", battery.DesignVoltage)\n\t}\n}\n```\n\nCLI\n---\n\nThere is also a little utility which - more or less - mimicks the GNU/Linux `acpi -b` command.\n\n*Installation*\n\n```bash\n$ go install github.com/distatus/battery/cmd/battery@latest\n```\n\n*Usage*\n\n```bash\n$ battery\nBAT0: Full, 95.61% [Voltage: 12.15V (design: 12.15V)]\n```\n","funding_links":["https://github.com/sponsors/KenjiTakahashi"],"categories":["Microsoft Office","Miscellaneous","Go","杂项","其他杂项","雜項","Uncategorized","其他","\u003cspan id=\"其他-miscellaneous\"\u003e其他 Miscellaneous\u003c/span\u003e"],"sub_categories":["Uncategorized","Strings","Advanced Console UIs","未分类的","暂未分类","高级控制台界面","高級控制台界面","暂未分类这些库被放在这里是因为其他类别似乎都不适合。","交流","\u003cspan id=\"高级控制台用户界面-advanced-console-uis\"\u003e高级控制台用户界面 Advanced Console UIs\u003c/span\u003e"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdistatus%2Fbattery","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdistatus%2Fbattery","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdistatus%2Fbattery/lists"}