power-mode-switcher

Power Mode Switcher

Automatically switch power profiles between Balanced and Power Saver based on laptop power status (plugged/unplugged), including on boot and resume — now with cross‑distro support!

📂 Repository Layout

power-mode-switcher/
├── README.md            # This file
├── install.sh           # Cross‑distro installation script
├── uninstall.sh         # Uninstallation script
├── LICENSE
└── src/
├── power-mode-switch.sh   # Main switching script
├── 99-power-mode.rules    # udev rule
└── power-mode.service     # systemd service definition

⚙️ Supported Distributions


🛠️ Prerequisites


🚀 Installation

  1. Clone & enter repo
    git clone https://github.com/md8-habibullah/power-mode-switcher.git
    cd power-mode-switcher
    
  2. Make scripts executable

    chmod +x install.sh uninstall.sh src/power-mode-switch.sh
    
  3. Run the installer

    ./install.sh
    

    You’ll see coloured, step‑by‑step output:

    • Detects your package manager (apt, pacman, or dnf)
    • Installs power-profiles-daemon (or swaps in tuned‑ppd on Fedora ≥ 41)
    • Copies the switch script, udev rule, and systemd unit into place
    • Reloads systemd & udev, then enables all services

🔍 Testing & Manual Use

  1. Automatic switching

    • Plug or unplug your AC adapter → runs automatically
    • Suspend & resume → runs on wake
  2. Check current profile

    powerprofilesctl get
    

    (on Fedora/RHEL with tuned‑ppd you can also run tuned-adm active)

  3. Manual invocation

    sudo /usr/local/bin/power-mode-switch.sh
    

🛠 Uninstallation

In the repo directory:

./uninstall.sh

This will:

  1. Disable & remove the power-mode.service unit
  2. Remove /etc/udev/rules.d/99-power-mode.rules
  3. Remove /usr/local/bin/power-mode-switch.sh
  4. Reload systemd & udev rules

🔧 Customization


🆘 Troubleshooting


Supports Debian/Ubuntu, Zorin, Mint, Arch, Manjaro, EndeavourOS, Fedora, CentOS, RHEL and any system with systemd & udev. Created by Md. Habibullah (md8-habibullah)