Add battery drain analysis tool and update documentation

- Add battery-drain-analysis.sh: Comprehensive tool to identify battery draining processes
  - Shows top CPU and memory consumers
  - Identifies network-intensive applications
  - Analyzes browser tab usage (counts renderers)
  - Provides actionable recommendations
  - Checks WiFi power management status

- Update README.md with new features:
  - Document CPU power management capabilities (400MHz-4.2GHz dynamic scaling)
  - Add browser optimization tips (tab suspenders, task manager usage)
  - Add application management best practices
  - Document new scripts: cpu-power-control.sh, monitor-cpu-freq.sh, battery-drain-analysis.sh
  - Add BIOS configuration guide reference

- Improve battery life tips:
  - Close heavy browser tabs (can use 77%+ CPU per tab)
  - Install tab suspender extensions (saves 50-70% browser CPU)
  - Manage chat applications (Element/Slack/Discord)
  - Pause file sync services when on battery
  - Screen brightness recommendations

Identified issue: Single browser tab was using 77% CPU, reducing overall browser usage from 268% to 96% CPU
This commit is contained in:
rwiegand
2025-10-06 22:50:32 +02:00
parent b9e2c2a731
commit 6b4b9e0b50
2 changed files with 182 additions and 9 deletions

View File

@@ -4,16 +4,22 @@ A comprehensive tool suite for optimizing Linux laptop battery life using TLP an
## 🔋 Overview
This repository provides scripts, configurations, and tools to maximize your Linux laptop's battery life through advanced power management. The toolkit includes automated installation scripts, optimized configuration files, and monitoring tools.
This repository provides scripts, configurations, and tools to maximize your Linux laptop's battery life through advanced power management. The toolkit includes automated installation scripts, optimized configuration files, CPU power management tools, and real-time monitoring utilities.
**Key Achievement**: Dynamic CPU frequency scaling from 400 MHz (idle) to 4.2 GHz (turbo) on AC power, and 400 MHz to 2.2 GHz on battery for optimal battery life while maintaining responsiveness.
## ✨ Features
- **Dynamic CPU Frequency Scaling**: 400 MHz to 4.2 GHz on AC, 400 MHz to 2.2 GHz on battery
- **CPU Power Management**: Intel RAPL power limits with preset profiles
- **Real-time Monitoring**: CPU frequency, power consumption, and battery drain analysis
- **Automated Installation**: One-command setup for TLP and PowerTOP
- **Optimized Configurations**: Pre-tuned settings for maximum battery life
- **Monitoring Tools**: Real-time battery and power consumption monitoring
- **Power Analysis**: Detailed PowerTOP reports and recommendations
- **Profile Management**: Easy switching between power profiles
- **Safety First**: Backup and rollback capabilities
- **BIOS Configuration Guide**: Documentation for optimal firmware settings
## 🚀 Quick Start
@@ -60,21 +66,51 @@ cd battery_life
./scripts/tlp-manager.sh --profile powersave
```
### 5. CPU Power Management
```bash
# Show current CPU power status
./scripts/cpu-power-control.sh status
# Apply power presets
./scripts/cpu-power-control.sh preset dynamic # 400MHz-4.2GHz (recommended)
./scripts/cpu-power-control.sh preset balanced # 400MHz-2.2GHz (battery)
./scripts/cpu-power-control.sh preset max-performance # 1.6GHz-4.2GHz
# Set custom power limit
./scripts/cpu-power-control.sh set 25 # Set 25W power limit
# Monitor CPU frequencies in real-time
sudo ./scripts/monitor-cpu-freq.sh
```
### 6. Battery Drain Analysis
```bash
# Analyze what's draining your battery
./scripts/battery-drain-analysis.sh
```
## 📁 Directory Structure
```
battery_life/
├── scripts/
│ ├── install.sh # Installation script
│ ├── uninstall.sh # Uninstallation script
│ ├── battery-monitor.sh # Battery status monitor
│ ├── powertop-analyze.sh # PowerTOP analysis tool
── tlp-manager.sh # TLP configuration manager
│ ├── install.sh # Installation script
│ ├── uninstall.sh # Uninstallation script
│ ├── battery-monitor.sh # Battery status monitor
│ ├── battery-drain-analysis.sh # Identify battery draining processes
── cpu-power-control.sh # CPU power management tool
│ ├── monitor-cpu-freq.sh # Real-time CPU frequency monitor
│ ├── powertop-analyze.sh # PowerTOP analysis tool
│ └── tlp-manager.sh # TLP configuration manager
├── config/
│ ├── tlp.conf # Optimized TLP configuration
│ └── powertop.service # PowerTOP systemd service
│ ├── tlp.conf # Optimized TLP configuration
│ └── powertop.service # PowerTOP systemd service
├── docs/
── [Documentation files]
── BIOS-FIX.md # BIOS configuration guide
│ ├── powertop-guide.md # PowerTOP usage guide
│ └── tlp-configuration.md # TLP configuration details
└── README.md
```
@@ -219,6 +255,46 @@ Results vary based on:
- Existing system settings
- Battery age and health
## 💡 Additional Battery Saving Tips
### Browser Optimization
Browser tabs are often the biggest battery drain. **Recommended actions**:
1. **Install a tab suspender extension** (e.g., Suspender MV3, The Great Suspender)
- Automatically suspends inactive tabs
- Can save 50-70% of browser CPU usage
- Dramatically improves battery life
2. **Use Brave's Task Manager** (`Shift+Esc`)
- Identify and close CPU-intensive tabs
- Look for tabs using >20% CPU
3. **Close unused tabs regularly**
- Each tab consumes memory and CPU
- Aim for <20 active tabs
4. **Disable unnecessary extensions**
- Some extensions run constantly in background
- Check `chrome://extensions` regularly
### Application Management
1. **Close Element/Slack/Discord when not in use**
- Chat applications can use 15-30% CPU in background
- Use web versions when occasional access is needed
2. **Pause file sync services** (Nextcloud, Syncthing, Dropbox)
- Manually trigger sync when needed
- Prevents constant disk and network activity
3. **Reduce screen brightness**
- Screen is often 30-50% of power consumption
- Every 10% reduction saves significant battery
4. **Close VS Code/IDEs when not coding**
- Language servers and extensions consume CPU
- Properly exit rather than minimize
## 🔍 Troubleshooting
### Common Issues