A simple and elegant bash script to switch between system power management profiles on Linux systems. Designed for Linux Mint but compatible with any Linux distribution that uses power-profiles-daemon.
- Easy Power Profile Switching: Toggle between available system power profiles
- Colorful Output: Clean, color-coded terminal interface
- Multiple Usage Modes: Toggle, cycle, or set specific profiles
- Smart Profile Detection: Automatically detects available power profiles
- Comprehensive Status Display: Shows current profile with descriptions
- Error Handling: Robust error checking and user feedback
- Linux system with
power-profiles-daemoninstalled - Bash shell
powerprofilesctlcommand available
- ✅ Linux Mint
- ✅ Ubuntu 20.04+
- ✅ Fedora 34+
- ✅ GNOME-based distributions
- ✅ Most modern Linux distributions with systemd
# Clone the repository
git clone https://github.com/mahdidevlp/power-mode-switcher.git
cd power-mode-switcher
# Make the script executable
chmod +x power_mode_switcher.sh
# Run it
./power_mode_switcher.sh --help# Copy to system-wide location
sudo cp power_mode_switcher.sh /usr/local/bin/power-mode-switcher
# Now you can use it from anywhere
power-mode-switcher --toggle# Show current power profile status
./power_mode_switcher.sh --status
# Toggle between available profiles
./power_mode_switcher.sh --toggle
# Set specific power profile
./power_mode_switcher.sh --profile balanced
./power_mode_switcher.sh --profile power-saver
./power_mode_switcher.sh --profile performance
# Show help
./power_mode_switcher.sh --help| Option | Description |
|---|---|
-s, --status |
Show current power profile status |
-t, --toggle |
Toggle between available profiles |
-c, --cycle |
Cycle through common profiles (performance → balanced → power-saver) |
-p, --profile PROFILE |
Set specific power profile |
-h, --help |
Show help message |
| Profile | Description | Use Case |
|---|---|---|
| Performance | Maximum CPU performance, higher power consumption | Gaming, video editing, intensive tasks |
| Balanced | Balance between performance and battery life | General daily use |
| Power Saver | Optimize for battery life, reduced performance | Extended battery life, light tasks |
=== Power Management Status ===
Current Profile: balanced
Available Profiles:
● balanced (active)
Balance between performance and battery life
○ power-saver
Optimize for battery life, reduced performance
Switching from 'balanced' to 'power-saver'...
✓ Power profile set to: power-saver
- Optimized for battery life
- Reduced CPU performance
- Best for extending battery life
- Open System Settings → Keyboard → Shortcuts
- Add custom shortcut:
- Name: Toggle Power Mode
- Command:
/path/to/power_mode_switcher.sh --toggle - Key:
Ctrl+Alt+P(or your preference)
- Open System Settings → Shortcuts → Custom Shortcuts
- Add new shortcut with the command above
You can integrate this with system tray tools like zenity for GUI notifications:
# Example wrapper script for GUI integration
#!/bin/bash
RESULT=$(./power_mode_switcher.sh --toggle 2>&1)
zenity --info --text="$RESULT" --title="Power Mode Switcher"If your system supports additional power profiles, the script will automatically detect them. You can extend the script by modifying the profile descriptions in the show_status() function.
# Check available profiles on your system
powerprofilesctl list
# The script will automatically work with any available profiles-
"powerprofilesctl is not available"
# Install power-profiles-daemon sudo apt install power-profiles-daemon # Ubuntu/Debian sudo dnf install power-profiles-daemon # Fedora
-
"Permission denied"
# Make script executable chmod +x power_mode_switcher.sh -
"Profile not available"
- Check available profiles:
powerprofilesctl list - Your system may not support all profile types
- Check available profiles:
For troubleshooting, you can check the power-profiles-daemon status:
# Check daemon status
systemctl status power-profiles-daemon
# List available profiles
powerprofilesctl list
# Get current profile
powerprofilesctl getContributions are welcome! Please feel free to submit issues, feature requests, or pull requests.
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
- Follow bash best practices
- Use meaningful variable names
- Add comments for complex logic
- Test on multiple distributions when possible
This project is licensed under the MIT License - see the LICENSE file for details.
- Thanks to the
power-profiles-daemondevelopers - Inspired by the need for simple power management on Linux
- Built for the Linux Mint community
If you encounter any issues or have questions:
- Check the Issues page
- Create a new issue with:
- Your Linux distribution and version
- Output of
powerprofilesctl list - Error messages or unexpected behavior
- GUI version using zenity/kdialog
- Desktop environment integration
- Battery percentage-based automatic switching
- Custom profile creation support
- System tray indicator
- Notification support
Made with ❤️ for the Linux community