power/

directory
v0.5.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 17, 2026 License: MIT, MIT

README

lys-power

Adaptive battery charging and power profile switching for lys.

Documentation

A battery kept plugged in at 100% wears out fast. While the laptop is on AC, lys-power holds the charge between 75% and 80%, learns when the charger usually comes out, and charges to 100% in the two hours before that moment. It also switches the power-profiles-daemon profile on every AC edge: performance on AC, power-saver on battery. Optionally, as a user service, it sets the screen brightness from an ambient light sensor or short camera captures that are never kept or sent anywhere.

Install

On NixOS:

{
  inputs.lys.url = "github:stubbedev/lys";

  # in the NixOS configuration
  imports = [inputs.lys.nixosModules.lys-power];
  services.lys-power.enable = true;
}

The .deb and .rpm on the latest release install the system unit; enable it with systemctl enable --now lys-power. Automatic brightness is services.lys-power.autoBrightness.enable = true; on NixOS and systemctl --user enable --now lys-power-brightness elsewhere.

Usage

lys-power status    # the power source, thresholds, profile and prediction
lys-power full      # charge to 100% until the next unplug
lys-power predict   # the predicted unplug time

It runs as the lys-power system service, as root, since the charge thresholds in /sys/class/power_supply are root's to write. The manual describes the policy.

Directories

Path Synopsis
Package autobrightness is lys-power's session-bus contract for automatic backlight: the State property of dev.stubbe.lys.AutoBrightness1, its PropertiesChanged, and Resume.
Package autobrightness is lys-power's session-bus contract for automatic backlight: the State property of dev.stubbe.lys.AutoBrightness1, its PropertiesChanged, and Resume.
cmd
lys-power command
Command lys-power applies power-source policy on Linux laptops: it swaps the power-profiles-daemon profile on AC edges and adaptively moves the battery charge thresholds so the machine leaves the desk with a full battery without spending its life plugged in at 100%.
Command lys-power applies power-source policy on Linux laptops: it swaps the power-profiles-daemon profile on AC edges and adaptively moves the battery charge thresholds so the machine leaves the desk with a full battery without spending its life plugged in at 100%.
internal
ambient
Package ambient is the pure core of automatic brightness: the curve from room illuminance to backlight level, the smoothing of the illuminance, the hysteresis band, the gradual transition, the exposure bracketing of a camera estimate, and the rule deciding whether the backlight is still automatic brightness's to set.
Package ambient is the pure core of automatic brightness: the curve from room illuminance to backlight level, the smoothing of the illuminance, the hysteresis band, the gradual transition, the exposure bracketing of a camera estimate, and the rule deciding whether the backlight is still automatic brightness's to set.
autobright
Package autobright runs automatic brightness: it samples the room's light, smooths it, and carries the backlight along the curve in gradual steps, until someone else changes the backlight, which pauses it until Resume.
Package autobright runs automatic brightness: it samples the room's light, smooths it, and carries the backlight along the curve in gradual steps, until someone else changes the backlight, which pauses it until Resume.
camlight
Package camlight estimates the room's illuminance with a camera.
Package camlight estimates the room's illuminance with a camera.
config
Package config carries every path and tunable of lys-power, with environment overrides so tests and exotic setups can redirect the sysfs, state and runtime locations without recompiling.
Package config carries every path and tunable of lys-power, with environment overrides so tests and exotic setups can redirect the sysfs, state and runtime locations without recompiling.
daemon
Package daemon runs lys-power: one idempotent, side-effecting evaluation of power source, profile and charge thresholds, driven by events rather than a polling loop.
Package daemon runs lys-power: one idempotent, side-effecting evaluation of power source, profile and charge thresholds, driven by events rather than a polling loop.
history
Package history keeps the log of when the charger came out, which is the training data for the unplug-time prediction.
Package history keeps the log of when the charger came out, which is the training data for the unplug-time prediction.
lightsensor
Package lightsensor reads an IIO ambient light sensor through sysfs: in_illuminance_input in lux where the driver processes the value, else (in_illuminance_raw + in_illuminance_offset) × in_illuminance_scale as the IIO ABI defines it, an absent offset being 0 and an absent scale 1.
Package lightsensor reads an IIO ambient light sensor through sysfs: in_illuminance_input in lux where the driver processes the value, else (in_illuminance_raw + in_illuminance_offset) × in_illuminance_scale as the IIO ABI defines it, an absent offset being 0 and an absent scale 1.
predict
Package predict estimates the next unplug time from the recorded history.
Package predict estimates the next unplug time from the recorded history.
profiles
Package profiles talks to power-profiles-daemon over the system bus, and decides which profile belongs on which power source.
Package profiles talks to power-profiles-daemon over the system bus, and decides which profile belongs on which power source.
statefile
Package statefile writes the manager's small state files atomically: a crash or power loss mid-write leaves the previous content in place, never a truncated file.
Package statefile writes the manager's small state files atomically: a crash or power loss mid-write leaves the previous content in place, never a truncated file.
supply
Package supply reads and writes the kernel's power supply interfaces: AC presence from /sys/class/power_supply and the battery charge thresholds the embedded controller honors.
Package supply reads and writes the kernel's power supply interfaces: AC presence from /sys/class/power_supply and the battery charge thresholds the embedded controller honors.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL