{"id":13994857,"url":"https://github.com/imwally/battstat","last_synced_at":"2025-10-24T05:30:28.389Z","repository":{"id":146253715,"uuid":"75998263","full_name":"imwally/battstat","owner":"imwally","description":"🔋 CLI battery status indicator for macOS, Linux, and OpenBSD ⚡","archived":false,"fork":false,"pushed_at":"2024-03-29T04:33:28.000Z","size":476,"stargazers_count":136,"open_issues_count":1,"forks_count":7,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-01-30T23:41:20.670Z","etag":null,"topics":["battery","linux","macos","openbsd"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/imwally.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}},"created_at":"2016-12-09T03:29:56.000Z","updated_at":"2024-09-18T18:31:47.000Z","dependencies_parsed_at":null,"dependency_job_id":"26e1ff39-f06f-4b33-bc58-3b78e5485ce3","html_url":"https://github.com/imwally/battstat","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imwally%2Fbattstat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imwally%2Fbattstat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imwally%2Fbattstat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imwally%2Fbattstat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/imwally","download_url":"https://codeload.github.com/imwally/battstat/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237915423,"owners_count":19386724,"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","linux","macos","openbsd"],"created_at":"2024-08-09T14:03:08.864Z","updated_at":"2025-10-24T05:30:27.959Z","avatar_url":"https://github.com/imwally.png","language":"Shell","readme":"# battstat\n\n`battstat` is a shell script that displays formatted information about the status of your battery. \n\n![battery discharging](/img/discharging.png)\n\n## Examples\n\nThere are a few ways to customize the output of `battstat`. Charging and discharging icons can be replaced with single character or multi-character strings. The `-c` flag sets the charging string and the `-d` flag sets the discharging string.\n\n```\n~ % battstat -d \"💀\"\n11:25 74% 💀\n\n~ % battstat -d \"😎\" -f \"{i} ({t})\"\n😎 (11:15)\n\n~ % battstat -c \"AC:\" -d \"BAT:\" -f \"{i} {p} {t}\"\nBAT: 74% 11:35\n\n~ % battstat -d \"Battery:\" -f \"{i} {p}\"\nBattery: 74%\n```\n\n## Formatting\n\n`battstat` uses printf style formatting when using the `-f` flag. This means you can print replacement tokens however you want.\n\n```\n~ % battstat -f \"{i}\\t{t}\\t({p})\"               \n🔋      11:55   (74%)\n\n~ % battstat -f \"{i}\\nType whatever you want.\\n{t}\\n({p})\" \n🔋\nType whatever you want.\n12:05\n(73%)\n```\n\n## macOS menu bar\n\n![bitbar screenshot](/img/bitbar.png)\n\nUsing [bitbar](https://github.com/matryer/bitbar) you can add the output of `battstat` to the menu bar on macOS. There are many ways to customize the output so I suggest reading over the [writing plugins](https://github.com/matryer/bitbar#writing-plugins) section to understand what's possible.\n\nThe screenshot above is using the following shell script. Make sure the script is executable and placed in the bitbar plugins path.\n\n```\n#!/bin/sh\n\ntime=$(/usr/local/bin/battstat -f {t})\n\necho \"($time) | size=13\"\n```\n\n## Supported Operating Systems\n\n* __macOS__: Details are collected via `pmset(1)`.\n* __Linux__: Details are collected via `upower(1)`.\n* __OpenBSD__: Details are collected via `apm(8)`.\n\n## Notes\n\nThe script does not account for laptops with multiple batteries. Newer ThinkPad models include both a swappable and non-swappable battery which may cause problems when searching for the battery with `upower`. I currently don't have the means necessary to test against these models but pull requests are of course welcomed.\n\n## Install\n\n1. Grab the script. Here are a few options:\n\n    * Download and extract the [zip](https://github.com/imwally/battstat/archive/master.zip).\n    * `$ git clone https://github.com/imwally/battstat`\n    * `$ curl -O https://raw.githubusercontent.com/imwally/battstat/master/battstat`\n\n2. Move it to your favorite binary path and make it executable.\n\n```\n$ mv battstat /usr/local/bin\n$ chmod u+x /usr/local/bin/battstat\n```\n\n## Usage\n\n```\nusage: battstat [options] format\n\noptions:\n    -h, --help                display help information\n    -c, --charging-icon       string to display in icon's place when battery is charging\n    -d, --discharging-icon    string to display in icon's place when battery is discharging\n    -f, --format              formatted output of battstat\n    --percent-when-charged    only display percent when charged\n\nformat replacement tokens:\n    {i}    display icon\n    {t}    display time remaining\n    {p}    display percent\n\nexample:\n    battstat -f \"Cool Battery: {t} ({p})\"\n```\n","funding_links":[],"categories":["Shell"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimwally%2Fbattstat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fimwally%2Fbattstat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimwally%2Fbattstat/lists"}