Possible to implement battery charge threshold on {Free,Net,Open}BSD? reddit / BSD ---------------------------------------------------------------------- [deleted] · 2019-10-07 19:38 [deleted] ---------------------------------------------------------------------- Ottaviocr · 2019-10-07 19:39 ---------------------------------------------------------------------- ZarK-eh · 2019-10-07 20:31 Is Tip only for thinkpads? While distro hopping, power management on a laptop is pretty important as well as servers. A server will run longer during battery only events. My windows laptops and servers get power options tweaks (power button is on/off, low and critical battery levels raised). On my freenas and opensense installs expose powerd simplistic control and I wants MOAH! ... too ---------------------------------------------------------------------- Ottaviocr · 2019-10-07 21:07 ---------------------------------------------------------------------- SaturnFive · 2019-10-07 21:52 One could take a look at `sysctl hw.sensors` if the hardware supports it and write a wrapper around it do to different things based on the values. On my system I have various `hw.sensors.acpibat0` values for displaying the max and current battery capacity and an AC power indicator. ---------------------------------------------------------------------- Ottaviocr · 2019-10-08 07:49 ---------------------------------------------------------------------- liveoneggs · 2019-10-08 12:02 "no demand" so "netbsd won't do it" doesn't seem to add up ;) ---------------------------------------------------------------------- Ottaviocr · 2019-10-08 17:13 ---------------------------------------------------------------------- sehnsuchtbsd · 2019-10-08 19:12 What is it you're exactly looking for? NetBSD's [powerd(8)](https://netbsd.gw.com/cgi-bin/man-cgi?powerd+8+NetBSD- current) allows an acceptable degree of tinkering and customization through a series of event [scripts](http://cvsweb.netbsd.org/bsdweb.c gi/src/etc/powerd/scripts/?only_with_tag=MAIN), similarly to Linux acpid ---------------------------------------------------------------------- Ottaviocr · 2019-10-08 19:30 I'm pretty sure one could hack the sensor_battery script to make something out of it. I'm not sure powerd exposes the battery charge levels or it can activate them. I'll have to ask that on irc tomorrow. ---------------------------------------------------------------------- sehnsuchtbsd · 2019-10-08 21:04 > I'm not sure powerd exposes the battery charge level [envstat(8)](https://netbsd.gw.com/cgi-bin/man-cgi?envstat+8+NetBSD- current) does; check also [envsys(4)](https://netbsd.gw.com/cgi- bin/man-cgi?envsys+4+NetBSD-current) ; I use envstat to generate battery charge lebel indicators for conky, tint2, etc... ---------------------------------------------------------------------- Ottaviocr · 2019-10-08 21:28 but can you then manipulate these indicators and set a range of battery level charges? Let's say: charge between 50 and 60%? As long as I understand, envsys can only indicate overcharging and high- capacity. ---------------------------------------------------------------------- sehnsuchtbsd · 2019-10-09 04:31 definitely, you're right here: I was rather thinking about using the envsys framework as an acpi abstraction layer for any powerd script you'd have potentially created ;) ---------------------------------------------------------------------- linrunner · 2019-10-13 17:33 ThinkPads (beginning with the \*20 generation) provide a distinct set of ACPI calls for (1) thresholds and force\_discharge (2). On Linux (1) has been implemented in the thinkpad\_acpi kernel driver, the corresponding patches which contain the calls are listed [here](https: //github.com/linrunner/TLP/issues/321#issuecomment-379813611). For (2) – and also (1) – there is an older user space implementation called [tpacpi-bat](https://github.com/teleshoes/tpacpi-bat) using a [generic kernel driver](https://github.com/teleshoes/acpi_call) to issue the same ACPI calls. tpacpi-bat may also serve as a reference. So the task seems to implement said ACPI calls in the BSD kernel. Hope it helps. ps. i'm TLP's author. ---------------------------------------------------------------------- Ottaviocr · 2019-10-15 10:22 Thanks. I was going to ask that on Github. I'll feedback that to the NetBSD kernel hackers.