Discussion:
Programmatically getting battery status
Ken Brown
2018-01-10 20:17:49 UTC
Permalink
On most platforms Emacs is able to display battery status on its mode
line. I'd like to try to implement this on Cygwin, but I could use some
pointers on how to get started and what method would be preferred.

Emacs uses /proc/apm, /proc/acpi/battery, or /sys/class/power_supply/ on
Linux; /usr/sbin/apm on BSD; pmset on macOS; and GetSystemPowerStatus on
Windows.

What would be the preferred approach on Cygwin? Based on absolutely no
knowledge, my instinct would be to use GetSystemPowerStatus to populate
a suitable file in /proc and/or to write a utility (usr/sbin/apm.exe).
But I have no specific ideas beyond that.

Ken
Ken Brown
2018-01-11 00:01:30 UTC
Permalink
Post by Ken Brown
On most platforms Emacs is able to display battery status on its mode
line.  I'd like to try to implement this on Cygwin, but I could use some
pointers on how to get started and what method would be preferred.
Emacs uses /proc/apm, /proc/acpi/battery, or /sys/class/power_supply/ on
Linux; /usr/sbin/apm on BSD; pmset on macOS; and GetSystemPowerStatus on
Windows.
What would be the preferred approach on Cygwin?  Based on absolutely no
knowledge, my instinct would be to use GetSystemPowerStatus to populate
a suitable file in /proc and/or to write a utility (usr/sbin/apm.exe).
But I have no specific ideas beyond that.
On second thought, unless people would find this useful for other
purposes, I may be losing motivation to work on this. It turns out that
the Emacs function for getting battery status in the Windows build is
already built into the Cygwin emacs-w32 build. It shouldn't be hard to
make Cygwin's emacs-nox and emacs-X11 use this function also.

Ken

Loading...