gpuswitch-cli

📜 Headless & Scripting

Use the integrated, discrete, auto, and status subcommands non-interactively from shell scripts and automations.

Every mode is available as a direct subcommand, so gpuswitch drops cleanly into shell scripts, aliases, and automations without opening the TUI.

📋 CLI Reference

CommandDescription
gpuswitchOpen the interactive TUI (↑↓ + enter)
gpuswitch integratedSwitch to the integrated GPU only
gpuswitch discreteSwitch to the discrete GPU only
gpuswitch autoLet macOS manage GPU switching
gpuswitch statusPrint the current GPU mode
gpuswitch --helpShow usage (-h also works)

🚦 Exit codes

  • A successful mode switch prints GPU mode set to: <mode> and exits 0.
  • A failed switch prints error: failed to set GPU mode to <mode> to stderr and exits 1.
  • An unknown command prints the usage text to stderr and exits 1.

💡 Examples

Save battery before unplugging:

gpuswitch integrated

Read the current mode into a variable:

mode=$(gpuswitch status)   # → "current GPU mode: integrated"

Switch to full performance only when on AC power:

if pmset -g batt | grep -q "AC Power"; then
  gpuswitch discrete
else
  gpuswitch integrated
fi

🔐 sudo and automations

Switching always runs sudo pmset -a gpuswitch <value>, which prompts for a password. For unattended automations (cron jobs, Raycast scripts, launch agents), grant passwordless pmset access via a sudoers rule so the command can run without an interactive prompt:

# /etc/sudoers.d/gpuswitch — edit with `sudo visudo -f /etc/sudoers.d/gpuswitch`
yourusername ALL=(ALL) NOPASSWD: /usr/bin/pmset

Granting passwordless pmset widens what runs without a prompt — scope it to your own user and only enable it if you trust the automation invoking it.

On this page