Last active
July 24, 2026 18:21
-
-
Save solanto/0d44622008381e47c0d71404e23b4d62 to your computer and use it in GitHub Desktop.
cycle performance modes via ACPI, suitable for GNOME keybinding
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # gnome queues up multiple runs if you inevitably hold down a keybinding | |
| # for more than a tick; detect other instances of this program or its | |
| # children (like tee) and exit if any exist | |
| MY_PID=$$ | |
| SCRIPT_NAME=$(basename "$0") | |
| RUNNING_INSTANCES=$(pgrep -f "$SCRIPT_NAME" | grep -v "$MY_PID" | wc -l) | |
| if [ "$RUNNING_INSTANCES" -gt 0 ]; then | |
| exit 0 | |
| fi | |
| if pgrep -x "tee" >/dev/null; then | |
| exit 0 | |
| fi | |
| # cycle performance profiles | |
| PROFILE_PATH="/sys/firmware/acpi/platform_profile" | |
| current=$(cat "$PROFILE_PATH") | |
| case "$current" in | |
| "quiet") next_mode="balanced" ;; | |
| "balanced") next_mode="performance" ;; | |
| "performance") next_mode="quiet" ;; | |
| *) next_mode="balanced" ;; | |
| esac | |
| echo "$next_mode" | sudo /usr/bin/tee "$PROFILE_PATH" > /dev/null | |
| echo "performance mode changed to: $next_mode" | |
| sleep 0.3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment