XQuartz: Enable ‘Allow connections from network clients’ via command line

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 ?


Solution 1:

Thanks @nohillside♦ and @dan for your answers.

In my case the command defaults write org.macosforge.xquartz.X11.plist nolisten_tcp 0 had had no effect. After some investigation I've figured out that the plist filename is a bit different in my system. So the command that ultimately worked for me is:

defaults write org.xquartz.X11.plist nolisten_tcp -bool false

Note that macosforge has been shutdown and projects moved to other places - so removing macosforge from the default name makes sense.