8000
Skip to content

Instantly share code, notes, and snippets.

@solanto
Last active July 24, 2026 18:21
Show Gist options
  • Select an option

  • Save solanto/0d44622008381e47c0d71404e23b4d62 to your computer and use it in GitHub Desktop.

Select an option

Save solanto/0d44622008381e47c0d71404e23b4d62 to your computer and use it in GitHub Desktop.
cycle performance modes via ACPI, suitable for GNOME keybinding
#!/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
0