How to change X11/Xquartz colour setting to 256 colors Using Bash Script? I want to change X11 color settings from 'From Display'(default) to '256 colors' using Terminal.app.  I already know how to change it using the GUI, but I need a bash script to do it.  I have:


Mavericks 10.9.5
XQuartz 2.7.7 (xorg-server 1.15.2)
MacbookPro
The command to change Color: From Display, as shown in X11 Preferences of XQuartz, to  Color: 256 Colors, from the command line in Terminal is:

defaults write org.macosforge.xquartz.X11 depth -int 8



Note: XQuartz should be closed when making this change or the ones below, from the command line or from within a bash script.




To reset it to the default, Color: From Display, use the following:

defaults delete org.macosforge.xquartz.X11 depth


Or: 

defaults write org.macosforge.xquartz.X11 depth -int -1



Note: By default the depth key doesn't exist however, when reset from the GUI to the default, the setting is -1, although either is acceptable to set the default back to Color: From Display.