Restructure loops, add explicit error handling, improve multi‑line messages, and fix formatting issues. - Enhancements - Use explicit braces for error branches to prevent silent failures - Wrap warning and informational messages in multi‑line `println!` with consistent spacing - Refactor directory reads for Ideapad fallback to avoid nested `let` bindings - Improve parsing and formatting of AMD TDP limit output with clear parentheses - Provide clearer debug logging when writing to threshold files - Bug Fixes - Added missing braces around error handling to ensure proper execution flow - Fixed variable binding scope for `ideapad_entries` to prevent shadowing - Ensured consistent handling of missing `charge_control_end_threshold` across all entries no changes.
lapctl
lapctl is a powerful, dependency-free command-line utility written in Rust. It is designed to provide seamless hardware management for Linux laptops.
By interfacing directly with the Linux kernel and ACPI endpoints, lapctl provides a unified interface for controlling hybrid GPU modes, battery charging thresholds, and thermal/power profiles—all from the terminal.
Key Features
- Hybrid GPU Management: Switch effortlessly between Integrated, Nvidia, and Hybrid graphics modes (Optimus).
- Battery Health: Enforce battery charging thresholds (e.g., 80%) to maximize chemical lifespan.
- Power Profiling: Dynamically adjust ACPI Platform Profiles, CPU scaling governors, and TDP (Wattage) limits.
- Thermal Controls: Direct hardware hooks for proprietary cooling solutions (e.g., Lenovo Ideapad, ASUS).
- Hardware Polling: Comprehensive hardware status checking without heavy daemon dependencies.
Example CLI
# GPU Modes
lapctl gpu integrated
lapctl gpu hybrid
lapctl gpu nvidia
# Battery Controls
lapctl battery limit 80
lapctl battery status
# Power Profiles
lapctl power performance
lapctl power balanced
lapctl power battery-save
# Raw Wattage Capping
lapctl power limit-tdp 35
# Cooling/Thermal Overrides (Lenovo/ASUS)
lapctl cooling performance
lapctl cooling balanced
lapctl cooling quiet
# Check All Hardware
lapctl status
# --- lapctl status ---
# GPU Mode: hybrid
# BAT1:
# Capacity: 99%
# Status: Full
# Charge Limit: 100%
# Power Profile: balanced
# Cooling Profile: Balanced (Ideapad)
# CPU TDP Limit: Hardware Managed
Built With
- Rust
- Modern Linux system interfaces
Project Structure
lapctl
│
├── Cargo.toml
├── README.md
├── LICENSE
├── .gitignore
│
├── src/
│ ├── main.rs
│ ├── cli.rs
│ │
│ ├── commands/
│ │ ├── mod.rs
│ │ ├── gpu.rs
│ │ ├── battery.rs
│ │ ├── power.rs
│ │ ├── cooling.rs
│ │ └── status.rs
│ │
│ ├── hardware/
│ │ ├── mod.rs
│ │ └── gpu.rs
│ │
│ └── utils/
│ └── system.rs
Core Capabilities
- CLI structure and routing architecture
- GPU mode switching and configuration orchestration
- Battery charge limit management (sysfs & Ideapad conservation mode)
- Comprehensive hardware status polling
- Configuration support and state caching
- Thermal/Cooling profiles (Lenovo VPC / ASUS WMI)
- CPU TDP (Wattage) Control (Intel RAPL / AMD hwmon)
Contributing
Contributions, ideas, and feature suggestions are welcome. More contribution guidelines will be added once the project reaches its first stable milestone.
Credits
Special thanks to EnvyControl by bayasdev. lapctl drew heavily from EnvyControl's structural logic for seamlessly handling hardware configurations across Linux environments.
License
This project is licensed under the MIT License.
You are free to use, modify, and distribute this software under the terms of the license. For full details, see the LICENSE file in this repository.
⭐ If you find this project interesting, consider starring the repository to follow its progress.