The above code is pretty much self explanatory, so there's little more to add.
Can you please explain to me what you asking with the command line?
The OS passes a command line parameter depending on which mode it wants the screensaver to start in (see code comments). How do you configure it too????
That's entirely up to your screensaver, if required at all (again, see code comments).