To build from the command line without the GUI.
displayctl
The source is here
To build
gcc -o displayctl main.c -framework IOKit -framework CoreFoundation
Or a Makefile
all: displayctl
displayctl: main.c
gcc -o displayctl -framework IOKit -framework CoreFoundation main.c