Skip to content

Commit

Permalink
✨📝 Power + docs
Browse files Browse the repository at this point in the history
  • Loading branch information
MathieuDR committed Dec 8, 2024
1 parent fc53e5a commit bfca3db
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 7 deletions.
39 changes: 39 additions & 0 deletions POWER.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# ThinkPad Power Management Guide

## Battery Status Commands
```bash
# Detailed battery information
upower -i /org/freedesktop/UPower/devices/battery_BAT0

# TLP battery status and thresholds
sudo tlp-stat -b

# ACPI information (temperature, cooling)
acpi -V
```

## Battery Charge Control
```bash
# Set full charge mode (useful before travel)
sudo tlp setcharge 5 100 BAT0

# Return to battery-preserving thresholds
sudo tlp setcharge 60 80 BAT0
```

These commands are temporary. After reboot, your NixOS configuration thresholds (60-80) will be restored.

## TLP Configuration Explained

Our configuration (`services.tlp.settings`) manages several power aspects:

1. **Battery Thresholds** (60-80%): Extends battery lifespan by preventing full charges and deep discharges
2. **CPU Management**: Performance on AC, power saving on battery
3. **Disk & PCIe**: Balanced power/performance settings
4. **WiFi & USB**: Power saving features with longer timeouts on AC
5. **USB Device Exceptions**: Prevents power management for specific USB devices (keyboard, mouse) to ensure responsiveness

## Power Alerts (UPower)
- Low Battery: 15%
- Critical: 10%
- Emergency Action (Hibernate): 5%
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ This repository contains a NixOS system configuration using the Flakes feature.
- Git configuration
- Custom terminal setup (Kitty)
- **Gaming Support** with Steam and Prismlauncher
- [**Power management**](POWER.md)
- **Custom Scripts** for:
- Power management
- Window management
Expand Down
7 changes: 6 additions & 1 deletion configuration/nixos/optional/power-management.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{...}: {
{pkgs, ...}: {
services.tlp = {
enable = true;
settings = {
Expand Down Expand Up @@ -51,4 +51,9 @@
# Power consumption analysis + auto-tuning on startup
powerManagement.powertop.enable = true;
services.acpid.enable = true;

environment.systemPackages = with pkgs; [
powertop
acpi
];
}
12 changes: 6 additions & 6 deletions modules/home-manager/wayland/waybar/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ in {
"clock"
];
modules-right =
[
optional cfg.battery "battery"
++ [
"group/info"
"wireplumber"
"network"
"group/tray"
"systemd-failed-units"
]
++ optional powerMenu.enable "custom/power"
++ optional cfg.battery "battery";
++ optional powerMenu.enable "custom/power";

"group/tray" = {
orientation = "horizontal";
Expand Down Expand Up @@ -196,11 +196,11 @@ in {

battery = mkIf cfg.battery {
format = "{icon} {capacity}%";
format-icons = ["" "" "" "" ""];
format-charging = " {capacity}%";
format-icons = ["󰂃" "󰁺" "󰁾" "󰂁" "󰁹"];
format-charging = "󰂄 {capacity}%";
interval = 30;
states = {
warning = 30;
warning = 25;
critical = 15;
};
};
Expand Down

0 comments on commit bfca3db

Please sign in to comment.