cscreen was created in 2003 for command line manipulation of video settings
Only a couple of changes have been made over the years in order to keep it viable as OS X has changed over time
I should have made this available a long time ago, and for those of you still interested, I'm making the source code available under the GNU GPL v3 license