Node.js Attempt at an AlDente-Style Battery Helper
Origin of the idea: battery degradation, expensive Mac repairs, and a practical need for charge-discipline alerts.
Origin of the Idea
I bought my MacBook Air M1 in 2022. Over the next two years, its battery degraded heavily. Battery health became unreliable and the machine barely lasted without power.
So I replaced the battery in September 2024.
Soon after replacement, on a rough morning while working, the Mac started heating suddenly. That became frustrating and scary, especially because Apple repairs and replacements are expensive, and at that time I did not have a stable income source.
So I had to find a solution.
Repair anxiety was the real trigger. This project started from a personal reliability problem, not from a “just for fun” experiment.
Discovering AlDente
I searched the web and quickly found AlDente.
What AlDente Does
AlDente is a macOS app built by AppHouseKitchen. It helps Mac users improve battery life using features like:
- charge limit control (for example, stop charging after 80%)
- calibration mode
- heat protection
- scheduled charging
It follows a freemium model, and for my use case the free version was sufficient.
All this made me curious as a developer: how is this done, and how far can I replicate the behavior technically?
Initial Thinking
I am a MERN stack developer, so my first thought was: can this be built using Node.js?
The Catch
Node.js cannot directly communicate with the kernel for low-level hardware control. It is ideal for application logic, APIs, and scripting, but direct hardware/system control generally needs lower-level integrations.
Node can interact with file systems through modules backed by native layers (for example through libuv-backed capabilities), but that is not equivalent to full hardware-level battery control.
Conclusion at this step: we cannot build full AlDente-level hardware control in plain Node.js alone.
Practical Goal Shift
If full battery-control is not feasible in pure Node.js, can we at least build a useful threshold alert workflow?
Yes: notify when charging crosses a limit, and notify when discharge falls below a lower bound.
Node.js Prototype Code
const batteryLevel = require("battery-level");
const notifier = require("node-notifier");
const isCharging = require("is-charging");
const CHARGE_LIMIT = 80;
const DISCHARGE_THRESHOLD = 40;
async function checkBatteryStatus() {
const level = (await batteryLevel()) * 100;
console.log(`Current battery level: ${level.toFixed(2)}%`);
const isChargingNow = await isCharging();
console.log(`Battery is ${isChargingNow ? "charging" : "not charging"}`);
if (level >= CHARGE_LIMIT && isChargingNow) {
notifier.notify({
title: "Battery Charge Alert",
message: `Battery has reached ${CHARGE_LIMIT}%. Unplug the charger to prolong battery life.`,
});
}
if (level <= DISCHARGE_THRESHOLD && !isChargingNow) {
notifier.notify({
title: "Battery Charge Alert",
message: `Battery level is low (${level.toFixed(2)}%). Consider plugging in the charger.`,
});
}
}
setInterval(checkBatteryStatus, 5 * 60 * 1000);
What This Code Actually Achieves
- Reads current battery level
- Detects charging vs discharging state
- Sends desktop notifications at upper/lower thresholds
- Runs on a periodic check interval
What This Is (and Isn’t)
This is not a full AlDente replacement.
It is a practical alert assistant built with a few packages and simple control flow.
The real heroes here are the package authors, especially Andreas Gillström for
battery-levelandis-charging.
Final Thought
If you are a Mac user, take a minute to appreciate the AlDente team for what they have built.
Thank you.