Skip to main content

Module power

Module power 

Source
Expand description

What this computer says of itself, for work it may do while you are away (the spam filter’s training by itself: docs/spam-filter.md, “Training by itself”): on mains power or on its battery, saving power or not, idle or in use, its connection metered or not. Each fact is None when this computer cannot tell it (no such service, no answer in time, a system not read here): whoever decides counts an unknown fact as not holding.

  • Linux and the BSDs, over D-Bus: UPower’s OnBattery; power-profiles-daemon’s ActiveProfile, under both of its names (org.freedesktop.UPower.PowerProfiles, the older net.hadess.PowerProfiles); the session’s idle time (the desktop’s org.freedesktop.ScreenSaver, in milliseconds as KDE gives it, GNOME’s org.gnome.Mutter.IdleMonitor) and whether it is locked (both screen savers, logind’s LockedHint; logind’s IdleHint only as a word for idle, since some desktops never set it); NetworkManager’s Metered.
  • Windows: GetSystemPowerStatus (its AC line, its battery saver), GetLastInputInfo. The connection’s cost is not read: unknown.
  • macOS: IOKit’s power sources, Low Power Mode (as pmset -g says it), CGEventSourceSecondsSinceLastEventType. The connection’s cost is not read: unknown.
  • Android: nothing; a phone never trains.

Modules§

imp 🔒

Structs§

Power
What this computer says of itself now.

Constants§

ASK 🔒
How long one question to the system may take.
IDLE
How long without anyone’s hands on the computer counts as idle.

Functions§

idle_of
Idle, from what the session said: locked, idle; else the shortest time without input any source gave (the newest touch wins); nothing said, unknown.
metered_of
NetworkManager’s Metered (NMMetered): yes or guessed yes, metered; no or guessed no, not; unknown (0) or anything else, unknown.
read
Every fact, read now: a few questions to the system, a second each at most.
supply
Its power supply alone (mains, saving power): what a training running asks again and again, without the session’s questions.