Don't know if this is helpful or not, I have a perl script
here that's meant to run from cron every X minutes and do something depending on if it's night or day.
The fleshed out version on my system uses xbrightness to change the gamma in X. (Though it checks to see if a net cable is plugged in first, then it acts like it's always day because I'm in the house).
I know OSX is based on BSD, but I know nothing about the windowing system.