t2saild is a root-required POSIX-shell daemon for an Apple T2 battery that
keeps your derived usable charge capacity within a configured window. Charging a
battery to 100% and keeping it there is bad for the capacity of the battery over
time. This daemon allows you to set a maximum charge limit to reduce battery
degradation. The ideal state for a battery is half charged / half discharged,
but for practicality 4/5 of the charge capacity gives the best of both worlds:
Ready-To-Go capacity and longevity.
However, a fixed upper limit can cause repeated shallow charging after about 1%
of AC-connected drain, as the battery tends to very slowly lose charge, even
when connected to AC. This daemon doesn't just allow you to set a charge limit,
but it also allows you to avoid that repeated shallow cycling by introducing
sailing mode. So, you set an upper MAX and a lower MIN limit and the
daemon will charge to >=MAX and then "sail" to <MIN before charging again.
An optional profile pair lets t2saild manage CPU governors and, optionally,
energy-performance preferences from battery status. Omitting the pair disables
CPU management; there are no implicit profile defaults.
- Linux on Apple T2 hardware with a usable battery and a supported charge-limit interface
- OpenRC (optional)
- root access
findutilsand util-linux (/usr/bin/logger)cpupowerinPATH, with configured governors available, only when using an explicit profile pair- For a composite profile, EPP support and the named preference must be available in every affected CPU policy
- Hosts using only plain profiles require no EPP support.
A mouse or other peripheral that also appears as a battery supply is ignored.
The modern charge-limit node uses the macsmc-battery supply for charge
readings. Without that node, the daemon uses macsmc-battery when its type is
Battery. Otherwise it needs one supply whose type is Battery, whose scope is
System or absent/Unknown, and whose charge_now, charge_full, and
status can be read. Device supplies are ignored. A System supply outranks
absent or Unknown supplies. If the best remaining supplies tie, the daemon
stops before changing the charge limit.
From the checkout, install directly:
#
sudo make install
#You will need to build your service files.
On Artix Linux (OpenRC) however, build and install the package instead:
#
makepkg -si
#This will install the service file as well, but installation does not enable or start the service.
t2saild [-v|--verbose] [-V|--version] [-h|--help] MAX MIN [PROFILE BATPROFILE]
MAX is the upper threshold and MIN is the lower threshold. Both are
decimal-integer percentages satisfying exactly 20 <= MIN < MAX <= 99. Options
must precede positional operands. PROFILE and BATPROFILE are optional only
as a pair. When omitted, CPU management is disabled; there are no implicit
profile defaults. Configuration changes require a restart; there is no
configuration reload.
To print "[AVAILABLE GOVERNORS...] : [AVAILABLE EPPS...]" run
#
printf "%s : %s\n" \
"$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors)" \
"$(cat /sys/devices/system/cpu/cpu0/cpufreq/energy_performance_available_preferences)"
#The battery profile does not switch as soon as you unplug. The daemon waits for
five consecutive checks that report Discharging before selecting the battery
profile. Any other status returns it to the main profile.
Verbose mode includes the current governor and EPP reported for cpu0. If
either value cannot be read, it appears as unavailable. These are
system-reported snapshots, not proof of actual speed or energy use, and they do
not show whether every CPU has the same settings. Profile transitions are logged
even when verbose mode is off.
The shipped profiles are performance:performance and
powersave:balance_power. A plain profile changes only the governor. A profile
with EPP asks the daemon to apply both supplied values; it does not decide
whether that combination is sensible or useful.
MacBook behavior with intel_pstate is unverified. The driver may influence or
override the effective preference, especially with the performance governor;
powersave can still respond to load.
Direct invocation runs in the foreground and requires root for hardware control:
#
sudo /usr/bin/t2saild 83 77
sudo /usr/bin/t2saild --verbose 83 77 performance:performance powersave:balance_power
#With OpenRC, configure /etc/conf.d/t2saild, then enable and start it
explicitly.
t2saild_min=77
t2saild_max=83
t2saild_profile=performance:performance
t2saild_batprofile=powersave:balance_power
t2saild_args=""The shipped defaults are logical MAX=83 and MIN=77; charging uses physical
BCLM target 84 (MAX+1), while sailing uses physical BCLM target 76
(MIN-1). This lets the daemon reach its state change before the physical BCLM
charge limit is reached.
t2saild_args passes optional daemon flags before positional operands in the
order MAX, MIN, PROFILE, BATPROFILE. Leave it empty for no optional
flags. The shipped OpenRC values explicitly supply performance:performance and
powersave:balance_power, so that service remains CPU-enabled. For verbose
polling, use t2saild_args="--verbose"; OpenRC then invokes
t2saild --verbose MAX MIN PROFILE BATPROFILE.
#
sudo rc-update add t2saild default
sudo rc-service t2saild start
#Stopping while AC remains connected can let the battery top up toward 100. Remove AC before shutdown unless topping up while powered off is intended.
On a normal shutdown, when a profile pair is configured, the daemon restores the configured main profile. It returns the charge limit to its normal value whether or not a profile pair is configured. It does not save and restore the CPU settings from before startup. A forced stop, crash, or power loss may prevent these changes.