I have a 15" MacBook Pro from May 2019 with a Radeon Pro 555X 4 GB graphics card. I would like to change the Automatic Graphics Switching
setting with a terminal command.
4 Answers
The command sudo pmset -a gpuswitch n
will set the graphics switching, with the following values for n:
2 is integrated gpu both on cable and battery
1 is dedicated gpu only with power connected; integrated gpu on battery power
0 is dedicated gpu on both ac and battery
pmset -g
will show you the current configuration.

- 35,635
-
For me, running Catalina on a 2019 macbook pro 16", value 2 is AMD Radeon Pro on both cable and battery, 0 is Intel UHD Graphics on both cable and battery somehow reversed – Pencilcheck Dec 30 '19 at 08:55
-
1The value 1 is acting weird, not sure what it is doing, seems to alternate between the graphics card randomly – Pencilcheck Dec 30 '19 at 09:32
-
It seems like 1 is true automatic graphics switching determined by the OS I think but it doesn't follow the power source. I used https://support.apple.com/en-us/HT202053 to figure out which graphics card it is using – Pencilcheck Dec 30 '19 at 09:38
-
@Pencilcheck I'm running Catalina in 2019 macbook pro 16,oncable, when "automatic switching" checked, 2 and 0 both use the intergrated crad, and 1 will uncheck the "automatic switching" and using dedicated card. – user956609 Jun 17 '21 at 07:48
I find this https://discussions.apple.com/thread/8160651 but it not match my 2018 MacBook with macOS Mojave 10.14
0 = Does not use dedicated graphics
1 = Use dedicated graphics
2 = Switch automaticly is default value when "Automatic Graphics Switching" selected in energy in preference.
The -a
-b
-c
-u
flags determine whether the settings apply
to battery -b
, charger (wall power) -c
, UPS -u
or all -a
Check settings depended on charger/battery
pmset -g custom
Let system use dedicated graphics card when charger plugin
sudo pmset -c gpuswitch 1
Let system use graphics card auto switch when using battery
sudo pmset -b gpuswitch 2
Let system use auto switch on charger & battery sudo pmset -a gpuswitch 2

- 925
I did some googling, and I do not know of a native command line utility, or a third-party command line utility, that can toggle the state of automatic graphics switching; however it can be done from the command line by utilizing AppleScript to toggle the [√] Automatic graphics switching checkbox on the Energy Saver pane in System Preferences.
In lieu of finding a native command line utility, or a third-party command line utility, or until a better answer is posted, the following will allow you to toggle it from the command line in e.g. Terminal.
In Terminal, use the following compound command to create the file and open it:
touch togags; open togags
Copy and paste the example AppleScript code, shown further below, into the opened
togags
file.Save and close the file.
Make the file executable:
chmod u+x togags
I used togags
for: [tog]gle [a]utomatic [g]raphics [s]witching
You can now use it from the directory it's in using ./togags
otherwise /path/to/togags
; however, it's best if you place in into a directory that's within your PATH
statement. Then it can be used from anywhere by just togags
, (or whatever you actually named the executable).
NOTE: This will also require giving Terminal accessibility privileges for this to work properly.
Running the command twice, to show its output:
$ togags
Automatic Graphics Switching is: OFF
$ togags
Automatic Graphics Switching is: ON
$
The following example AppleScript code, was tested and works me as coded on macOS High Sierra. A minor change may be needed for macOS Mojave; however, I'm not able to test at the present time. The same goes for older versions of OS X/macOS.
Example AppleScript code:
#!/usr/bin/osascript
if running of application "System Preferences" then
try
quit application "System Preferences"
on error
do shell script "killall 'System Preferences'"
end try
end if
repeat while running of application "System Preferences" is true
delay 0.1
end repeat
tell application "System Preferences"
reveal pane id "com.apple.preference.energysaver"
repeat until exists window "Energy Saver"
delay 0.1
end repeat
end tell
tell application "System Events" to tell ¬
group 1 of window "Energy Saver" of application process "System Preferences"
repeat until exists checkbox "Automatic graphics switching"
delay 0.1
end repeat
click checkbox "Automatic graphics switching"
set cbAGS to (value of checkbox "Automatic graphics switching") as boolean
end tell
quit application "System Preferences"
if cbAGS then
return " Automatic Graphics Switching is: ON"
else
return " Automatic Graphics Switching is: OFF"
end if
Note: The example AppleScript code is just that and other then what's already coded, it does not contain any additional error handling as may be appropriate. The onus is upon the user to add any error handling as may be appropriate, needed or wanted. Have a look at the try statement and error statement in the AppleScript Language Guide. See also, Working with Errors.

- 58,676
-
1
-
@Dev, Please do not waste your time attempting to edit my answers in the manner you've tried to do this one, I will just reject your edits such as this every time! – user3439894 Jan 21 '21 at 02:51