{"id":19819708,"url":"https://github.com/primalmotion/battctl","last_synced_at":"2025-07-05T04:06:11.755Z","repository":{"id":138050671,"uuid":"402570458","full_name":"primalmotion/battctl","owner":"primalmotion","description":"Battery charge threshold controller for Librem 14","archived":false,"fork":false,"pushed_at":"2021-09-23T18:50:08.000Z","size":55,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-28T20:21:28.748Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/primalmotion.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":"2021-09-02T21:43:55.000Z","updated_at":"2024-12-28T16:53:27.000Z","dependencies_parsed_at":"2024-06-21T15:28:29.436Z","dependency_job_id":"f41455e0-a684-49e5-a8fb-595abe40f400","html_url":"https://github.com/primalmotion/battctl","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/primalmotion/battctl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/primalmotion%2Fbattctl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/primalmotion%2Fbattctl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/primalmotion%2Fbattctl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/primalmotion%2Fbattctl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/primalmotion","download_url":"https://codeload.github.com/primalmotion/battctl/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/primalmotion%2Fbattctl/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263679238,"owners_count":23495014,"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":[],"created_at":"2024-11-12T10:19:45.653Z","updated_at":"2025-07-05T04:06:11.736Z","avatar_url":"https://github.com/primalmotion.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# battctl\n\nbattctl is a tool that allows you to:\n\n- get the current charge threshold values\n- set the charge threshold values\n- monitor AC status through udev to apply one the the 2 charging modes\n\nThe thresholds for both modes (`mobile` or `docked`) can be individually\nconfigured. Each mode comes with a delay to define how long to wait\nafter the AC event to switch to the mode.\n\nFor instance, if the `docked` delay is 24h and the `mobile` delay is 30m,\nthis means that 24h hours after plugging the AC in, the thresholds will be\nupdated to the `docked` values. If you unplug the AC for less than 30m,\nthe thresholds will not change. After 30 minutes, the thresholds will be\nrestored to the `mobile` values. If you plug the AC back, it will take\n24h to switch to the `docked` values again.\n\n\u003e This requires your battery thresholds to be exposed in user-space.\n\u003e This program assumes the following paths exist by default:\n\u003e\n\u003e - `/sys/class/power_supply/BAT0/charge_control_end_threshold`\n\u003e - `/sys/class/power_supply/BAT0/charge_control_end_threshold`\n\u003e\n\u003e They can be changed using flags.\n\u003e This has only be tested on a Purism Librem 14. For anything else\n\u003e patches welcome!\n\n## Getting / Setting\n\nTo get the current values:\n\n\tbattctl get\n\nTo set the values:\n\n\tbattctl set 90 95\n\nWhere the first argument is the charge threshold start and the second the\ncharge threshold end.\n\n## Monitoring\n\nTo start the monitor:\n\n\tbattctl monitor\n\n### Flags\n\nThere are several options that you can use to set for how long to\nwait to switch from one mode to the other, and what thresholds to apply.\n\n\tbattctl monitor -h\n\tStarts the monitor daemon\n\n\tUsage:\n\t  battctl monitor [flags]\n\n\tFlags:\n\t      --data-clean                    Delete content of data folder before starting.\n\t      --data-dir string               Path to data folder. (default \"/var/lib/battctl\")\n\t  -d, --docked-delay duration         How long to wait before setting docked mode after power supply is plugged (default 24h0m0s)\n\t  -e, --docked-end int                Value for charge control threshold end in docked mode (default 95)\n\t  -s, --docked-start int              Value for charge control threshold start in docked mode (default 40)\n\t  -h, --help                          help for monitor\n\t  -D, --mobile-delay duration         How long to wait before setting mobile mode after power supply is unplugged (default 1m0s)\n\t  -E, --mobile-end int                Value for charge control threshold end on mobile (default 95)\n\t  -S, --mobile-start int              Value for charge control threshold start on battery (default 90)\n\t      --threshold-end-path string     Path to the charge control end file (default \"/sys/class/power_supply/BAT0/charge_control_end_threshold\")\n\t      --threshold-start-path string   Path to the charge control start file (default \"/sys/class/power_supply/BAT0/charge_control_start_threshold\")\n\n### systemd unit\n\nA systemd unit file can be found in the `dist` folder to deal with the monitor.\n\n### Config file\n\nThese values can be configured by creating a file in `/etc/battctl/conf.yaml`\nwhere the keys are the flags without their `--` prefix.\n\nFor example:\n\n\tdocked-delay: 48h\n\tdocked-start: 50\n\tdocked-end: 90\n\nAn example of a config file can be found in the `dist` folder.\n\n### State\n\nThe monitor keep tracks of the last mode and last time of even in\n`/var/lib/battctl/state` by default.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprimalmotion%2Fbattctl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprimalmotion%2Fbattctl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprimalmotion%2Fbattctl/lists"}