It seems I can't edit the plist file from LaunchAgents — even if I sudo, I'm prevented from any deletion/alteration. Do I have to necessarily disable SIP to do this?
According to this thread you can do:
defaults write com.apple.gamed Disabled -bool true
And to check the current state of the daemon use:
defaults read com.apple.gamed Disabled
One solution is to create a bash script to stop the gamed service after you login. Use Automator in OS X to create a bash script then add it as a Login Item to your OS X account. The next time you login you should receive a prompt to execute the script. Normally I wait until I see an alert from Little Snitch that gamed is phoning home then I click 'Continue' to run the script. This has not been perfected and you may encounter issues if you run it immediately after you login to OS X. I prefer to stay away from the solutions that disable the service as those require disabling/overriding SIP which I advise against.
Here is the bash script I use. Any suggestions on improving it are welcome.
#!/bin/bash chkService=gamed chkCount=10 chkStatus=$(ps ax | grep "$chkService" | grep -v grep | grep " T " | wc -l) while [ $chkStatus -ne 1 ]; do chkProcess=$(ps ax | grep -v grep | grep "$chkService" | wc -l) if [ $chkProcess -ne 0 ]; then KILLALL -STOP "$chkService" chkCount=0 chkStatus=$(ps ax | grep gamed | grep -v grep | grep " T " | wc -l) else SLEEP=1 chkCount=$((chkCount-1)) fi done
The problem is that the accepted answer given above:
launchctl unload /System/Library/LaunchAgents/com.apple.gamed.plist
no longer works. I have also seen it using the
-w flag. In any case, in recent updates, I think around El Capitan or Yosemite, you instead get a message
Operation not permitted while System Integrity Protection is engaged
System Integrity Protection is also known by the acronym SIP. To disable it you need to boot into the Recovery OS and run
I have done this sequence in previous releases and it did lead to being able to disable gamed via the
I suppose that after gamed is disabled, one could re-enable SIP. Maybe that would be the best of both worlds, although it is a tedious process all in all.
This makes little to no difference from a security standpoint as it simply reverts a system back to exactly ho wit worked prior to SIP, and exactly how almost all Unix systems still work. The value of SIP is at best debateable. It addresses the question because only way to use the Launchctl command to unload the gamed plist file is to first disable SIP, boot, unload the plist file, and then, if desired, reenable SIP.
Another option that works on 10.11.6 is a variation on the method suggested by @Le-Sci. Create a shell script that disables the gamed process:
#!/bin/bash sleep 30 && kill -9 "$(pgrep gamed)"
The sleep command here tells the script to wait 30 seconds before starting the process of quitting gamed, to give the system enough time to have loaded gamed before trying to terminate it; you can adjust the amount of time to wait as necessary. The "kill -9" command force-quits the process you request, but it only accepts a process id number, not a process name, so "pgrep" is used to look up the process id. Make a note of where you save the script (for this example, I will save it as "forceQuitGamed" in /Users/myaccountname/ ).
Give the script execution permission:
sudo chmod +x ~/forceQuitGamed
Create a launch agent plist file that will run each time you login to your account. If you have not created a plist file before, one way you can do this is with TextEdit. The script file must be saved in plain text, so if your default preferences for TextEdit call for Rich Text formatting, do a Format>Make Plain Text command to convert to plain text before trying to use the new launch agent plist file.
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>com.myaccountname.loginscript</string> <key>ProgramArguments</key> <array> <string>/Users/myaccountname/forceQuitGamed</string> </array> <key>RunAtLoad</key> <true/> </dict> </plist>
The string in the array under "ProgramArguments" is the path/to/your/shell script. Save the file to ~/Library/LaunchAgents/ . In this example, I named the plist file com.myaccountname.forceQuitGamed.plist, so it is found at
Now each time that you login to your account, gamed should be force-quit just a few seconds after it has loaded. (If you need it to be terminated as soon as possible after it is loaded, look at @Le-Sci's method.) This approach works without needing to disable System Integrity Protection.