How to change the the screensaver using terminal (without using Preference Panel)?

  1. Quit System Preferences.

  2. Locate the relevant plist in terminal by

    ls ~/Library/Preferences/ByHost/com.apple.screensaver.*.plist
    

    You should see something like

    /Users/<username>/Library/Preferences/ByHost/com.apple.screensaver.0B39A0DE-D1EE-59FF-85C0-6EA16FCB015B.plist
    

    Note that hyphen-delimited alphanumeric string. It might be host dependent, judging from that ByHost directory name. (Or maybe it's not. At the moment I have only one Mac at my disposal so I can't tell.)

  3. In terminal, run the following commands (with the hyphen-delimited alphanumeric string replaced by what you found in the last step):

    defaults write ~/Library/Preferences/ByHost/com.apple.screensaver.0B39A0DE-D1EE-59FF-85C0-6EA16FCB015B.plist moduleDict -dict moduleName iLifeSlideshows path /System/Library/Frameworks/ScreenSaver.framework/Resources/iLifeSlideshows.saver type 0
    defaults read ~/Library/Preferences/ByHost/com.apple.screensaver.0B39A0DE-D1EE-59FF-85C0-6EA16FCB015B.plist
    

That's it. There's one problem with this approach: it seems that multiple screensavers are registered with this iLifeSlideshows.saver (e.g. Classic), and I couldn't locate the plist controlling which one is shown. But according my testing, if you've chosen "Ken Burns" in System Preferences and later changed it to "Flurry", then when you run the above commands you will get "Ken Burns" back. Otherwise, no guarantee — for instance, you might get "Classic" if that's the last used one from iLifeSlideshows.saver.


Environment:
MacBook Pro (13-inch, Mid 2012)
macOS Sierra version 10.12.4

defaults -currentHost write com.apple.screensaver moduleDict -dict moduleName Flurry path /System/Library/Screen\ Savers/Flurry.saver/ type 0

to check:
defaults -currentHost read com.apple.screensaver
or

open /System/Library/CoreServices/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine.app

## older mac OS versions pre High-sierra
## open /System/Library/Frameworks/ScreenSaver.framework/Versions/A/Resources/ScreenSaverEngine.app



adapted from here:
http://krypted.com/mac-security/mac-setting-screen-saver-from-the-cli/
(But it needed to be updated/improved)