A lightweight battery charge threshold manager for Linux laptops.
Threshd allows you to cap your laptop's battery charging at a specific percentage (e.g., 80%) to extend battery lifespan. It provides a system tray icon for easy access and runs as a secure system daemon.
- Simple UI - System tray icon with quick preset buttons
- Real-time updates - Shows current battery level and charging status
- Secure - PolicyKit integration for safe privilege elevation
- Lightweight - Written in C, ~100KB total binaries
- Fast - Builds in seconds
git clone https://github.com/mateohysa/threshd.git
cd threshd
./install-c.shThat's it! The tray icon will appear automatically and start on future logins.
Not sure if your laptop is supported? Run ./check-hardware.sh first to verify.
The installation script will:
- Check for required system dependencies
- Build the daemon and tray application
- Install system-wide with proper permissions
- Enable and start the background daemon
- Launch the tray icon
If you prefer manual control:
# Install dependencies (Ubuntu/Debian)
sudo apt install build-essential pkg-config libglib2.0-dev \
libpolkit-gobject-1-dev libgtk-3-dev \
libayatana-appindicator3-dev zenity
# Build
make
# Install (requires sudo)
sudo make install
# Enable daemon
sudo systemctl enable --now threshdd.service
# Start tray
threshd-tray &Right-click the battery icon in your system tray to:
- Set threshold to 60%, 70%, 80%, or Uncapped (100%)
- Choose Custom... for any value between 60-100%
- View current battery percentage and threshold
The active threshold shows a ✓ checkmark.
Your laptop must support battery charge threshold control via sysfs:
ls /sys/class/power_supply/BAT*/charge_control_end_thresholdIf this file exists, you're good to go! This feature is available on:
- Most ThinkPad models
- Many Dell, HP, and ASUS laptops
- Framework laptops
- And many others
Check your manufacturer's documentation or BIOS settings if unsure.
cd threshd
sudo make uninstall┌─────────────────────────────────────────────────┐
│ threshd-tray │
│ (GTK3 system tray - runs as user) │
└────────────────┬────────────────────────────────┘
│
│ D-Bus
↓
┌─────────────────────────────────────────────────┐
│ threshdd │
│ (System daemon - runs as root) │
└────────────────┬────────────────────────────────┘
│
│ PolicyKit authorization
↓
┌─────────────────────────────────────────────────┐
│ /sys/class/power_supply/BAT0/ │
│ charge_control_end_threshold │
└─────────────────────────────────────────────────┘
# Clone the repository
git clone https://github.com/YOUR_USERNAME/threshd.git
cd threshd
# Build
make
# The binaries will be created:
# - threshdd (daemon)
# - threshd-tray (tray application)# Check if running
pgrep threshd-tray
# Restart
pkill threshd-tray && threshd-tray &# Check daemon status
sudo systemctl status threshdd.service
# View logs
sudo journalctl -u threshdd.service -fIf you get errors, your laptop may not support this feature. Check:
ls -l /sys/class/power_supply/BAT*/charge_control_*If these files don't exist, your hardware doesn't support threshold control.
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
# Build with debug symbols
make clean
make CFLAGS="-Wall -Wextra -g -DDEBUG"
# Run daemon manually for testing
sudo ./threshdd
# Run tray manually
./threshd-traythreshd/
├── src/
│ ├── threshdd.c # System daemon
│ └── threshd-tray.c # Tray application
├── resources/ # Icons, D-Bus configs, PolicyKit policies
├── Makefile # Build system
├── install-c.sh # Installation script
└── README.md
MIT License - see LICENSE file for details.
- Linux kernel power supply subsystem maintainers
- The GTK and libayatana-appindicator projects
- Everyone who has contributed to making laptop battery management better
Note: Setting a charge threshold to 80% or lower can significantly extend your battery's lifespan by reducing stress on the cells. This is especially useful for laptops that stay plugged in most of the time.