I'd like to write a shell script that uses xquartz.

Specifically the ‘Allow connections from network clients’ checkbox at Settings/Security has to be checked. Is there a way to do this programmatically ?


Xquartz settings are stored in ~/Library/Preferences/org.macosforge.xquartz.X11.plist, the key you are looking for is nolisten_tcp.

To allow connections from network clients use

defaults write org.macosforge.xquartz.X11.plist nolisten_tcp 0

To prevent connections use

defaults write org.macosforge.xquartz.X11.plist nolisten_tcp 1

For both cases Xquartz must not be running while you apply the change.

PS: To look at the content of the file you can use

plutil -p ~/Library/Preferences/org.macosforge.xquartz.X11.plist 
  • 's answer doesn't work for me. Looks like the command now should be: defaults write org.macosforge.xquartz.X11 nolisten_tcp -bool true plutil -p ~/Library/Preferences/org.macosforge.xquartz.X11.plist will indeed show the nolisten_tcp is now set to 1 But the change is temporary, as soon as I do startx, it gets reset to 0. Some others recommended adding nolisten_tcp -bool true directly to the defaultserverargs in the startx file but that has broken my startx. No solution to me as of now (sorry I can't write comments yet so this is 'answer') – Kristof Jun 9 at 22:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .