If I understand correctly, you want to check the battery level, and give you a notification when battery is low, right? 正しく理解しているなら、YASUOKAさんはバッテリーのレベルを確認し、 バッテリーが低くなったら通知を受け取りたい、ということですよね?
In this case, you can use apm for that. その場合、それには「apm」を使うことができます。 Battery level (percent) checking/バッテリーのレベル(パーセント)を確認するため:apm -l Estimated battery duration (minutes)/バッテリーが持つ予定の時間まで(分)を確認するため:apm -m On 2023年08月17日 16:12, YASUOKA Masahiko wrote: > Hi, > > Update the AC status when the battery notification is happened. > Because the AC status notification doesn't happen on some machines. > My vaio actually has this problem. > > Also Linux is doing the same thing > > https://github.com/torvalds/linux/blob/v6.4/drivers/acpi/ac.c#L165-L183 > > ok? comments? > > Index: sys/dev/acpi/acpiac.c > =================================================================== > RCS file: /cvs/src/sys/dev/acpi/acpiac.c,v > retrieving revision 1.36 > diff -u -p -r1.36 acpiac.c > --- sys/dev/acpi/acpiac.c 6 Apr 2022 18:59:27 -0000 1.36 > +++ sys/dev/acpi/acpiac.c 17 Aug 2023 06:57:44 -0000 > @@ -140,6 +140,8 @@ acpiac_getpsr(struct acpiac_softc *sc) > return (0); > } > > +static int acpiac_notify_triggered = 0; > + > int > acpiac_notify(struct aml_node *node, int notify_type, void *arg) > { > @@ -148,6 +150,8 @@ acpiac_notify(struct aml_node *node, int > dnprintf(10, "acpiac_notify: %.2x %s\n", notify_type, > DEVNAME(sc)); > > + acpiac_notify_triggered = 1; > + > switch (notify_type) { > case 0x00: > case 0x01: > @@ -164,4 +168,22 @@ acpiac_notify(struct aml_node *node, int > break; > } > return (0); > +} > + > +void > +acpiac_battery_notify(void) > +{ > + struct acpi_softc *sc = acpi_softc; > + struct acpi_ac *ac; > + > + if (acpiac_notify_triggered) > + return; > + /* > + * On some machines (vaio VJPK23 at least) AC status notifications > + * are not triggered. Update the AC status when battery notifications. > + */ > + SLIST_FOREACH(ac, &sc->sc_ac, aac_link) { > + acpiac_refresh(ac->aac_softc); > + acpi_record_event(sc, APM_POWER_CHANGE); > + } > } > Index: sys/dev/acpi/acpibat.c > =================================================================== > RCS file: /cvs/src/sys/dev/acpi/acpibat.c,v > retrieving revision 1.70 > diff -u -p -r1.70 acpibat.c > --- sys/dev/acpi/acpibat.c 6 Apr 2022 18:59:27 -0000 1.70 > +++ sys/dev/acpi/acpibat.c 17 Aug 2023 06:57:45 -0000 > @@ -536,5 +536,7 @@ acpibat_notify(struct aml_node *node, in > acpibat_refresh(sc); > acpi_record_event(sc->sc_acpi, APM_POWER_CHANGE); > > + acpiac_battery_notify(); > + > return (0); > } > Index: sys/dev/acpi/acpidev.h > =================================================================== > RCS file: /cvs/src/sys/dev/acpi/acpidev.h,v > retrieving revision 1.44 > diff -u -p -r1.44 acpidev.h > --- sys/dev/acpi/acpidev.h 29 Jun 2018 17:39:18 -0000 1.44 > +++ sys/dev/acpi/acpidev.h 17 Aug 2023 06:57:45 -0000 > @@ -306,6 +306,8 @@ struct acpiac_softc { > struct ksensordev sc_sensdev; > }; > > +void acpiac_battery_notify(void); > + > struct acpibat_softc { > struct device sc_dev; > > -- lain.