0

I have an art collection of 8000 pics, I have them divided into folders of about 200 each. I'm going to use python to randomly select one of these folders so that my screensaver will continually show me the work of a new artist rather than randomly mixing all the artists together. To do this I need to change the folder that the screensaver uses with Python which will then change the folder using Terminal.

I read this article and it seems that you can do that by using this command:

https://krypted.com/mac-security/mac-setting-screen-saver-from-the-cli/

defaults -currentHost write com.apple.screensaver modulePath -string "/users/kylefoley/pictures/art/art 2/impressionism/claude monet/"

But that didn't work. Also, I am using macos 10.14

UPDATE

When I input: /usr/bin/defaults -currentHost read com.apple.ScreenSaverPhotoChooser I get the expected result, viz, the actual folder that the screensaver is using. When I input: /usr/bin/defaults -currentHost write com.apple.ScreenSaverPhotoChooser SelectedFolderPath -string "/users/kylefoley/pictures/art/art 2/impressionism/claude monet/" then input /usr/bin/defaults -currentHost read com.apple.ScreenSaverPhotoChooser I get

{
    CustomFolderDict =     {
        identifier = "/Users/kylefoley/Pictures/art/complete art 2";
        name = "complete art 2";
    };
    SelectedFolderPath = "/users/kylefoley/pictures/art/art 2/impressionism/claude monet/";
    SelectedSource = 4;
    ShufflesPhotos = 1;
}

Which is wrong because the path for the CustomFolderDict['identifier'] should be the same as the SelectedFolderPath

I then made a guess and tried:

/usr/bin/defaults -currentHost write com.apple.ScreenSaverPhotoChooser CustomFolderDict -identifier "/users/kylefoley/pictures/art/art 2/impressionism/claude monet/"

which outputted Unexpected argument. If think I could figure out how to fix that CustomFolderDict with command line then that might solve the problem.

UPDATE 2

I inputted:

/usr/bin/defaults -currentHost write com.apple.ScreenSaverPhotoChooser CustomFolderDict -dict-add identifier "/users/kylefoley/pictures/art/art 2/impressionism/claude monet/"
/usr/bin/defaults -currentHost write com.apple.ScreenSaverPhotoChooser CustomFolderDict -dict-add name "claude monet"

And although I get

{
    CustomFolderDict =     {
        identifier = "/users/kylefoley/pictures/art/art 2/impressionism/claude monet/";
        name = "claude monet";
    };
    LastViewedPhotoPath = "";
    SelectedFolderPath = "/users/kylefoley/pictures/art/art 2/impressionism/claude monet/";
    SelectedSource = 3;
    ShufflesPhotos = 1;
}

When I input

/usr/bin/defaults -currentHost read com.apple.ScreenSaverPhotoChooser

The new result is just a blank screen with the name of my computer on it.

13
  • This article from OSXDaily shows all the common locations for screensaver files - am guessing if you put a softlink into the right place in ~/Library pointing to the above path they could be picked up.
    – Mr R
    Commented Mar 14, 2021 at 10:13
  • That's for screensavers that do something weird like some fractal, I just want it scroll through a set of images which it already does I just can't figure out the path to that folder of images.
    – bobsmith76
    Commented Mar 14, 2021 at 13:50
  • Oh you can also just add your own folder - in Screensavers pick a mode - say Ken Burns - on the right under source there's a choose folder option - you can select a folder of your choice (and it'll find all the images under there).
    – Mr R
    Commented Mar 14, 2021 at 14:02
  • I said in my post, that I have about 8000 pics divided into 200 folders. I want the folders to change randomly every hour or so. To do that I need to put a python script on infinite loop and then every hour it will choose a new folder using the subprocess module. I need to know how to change the folders using terminal.
    – bobsmith76
    Commented Mar 14, 2021 at 16:54
  • you didn't say which version of OSX - I tried an idea from JAMF forums - see answer.
    – Mr R
    Commented Mar 14, 2021 at 20:30

1 Answer 1

2

This works for me on a Catalina machine and is known to work on Mavericks (HT @bobsmith76 for persevering).

/usr/bin/defaults -currentHost write com.apple.ScreenSaverPhotoChooser 'SelectedFolderPath' "/Users/you/sub/sub/folder"

I used hot-corners to turn on the screen saver, and set different default, then when I enabled screen saver again it used the new folder.

NOTE if you have System Preferences open when making the changes then this may cause the wrong thing to happen (like the screensaver config flipping to a non-image screensaver - we both ended up on the Message screensaver this way).

4
  • Thanks for helping me out. I said in my OP that I am using 10.14. In any case, I couldn't get the above script to work for 10.14.
    – bobsmith76
    Commented Mar 15, 2021 at 4:40
  • In theory it ought to work on 10.14 - but I noticed that someone on the Jamf forum is asking why it worked in 10.14.2 and doesn't now (10.14.5) (community.spiceworks.com/topic/…)
    – Mr R
    Commented Mar 15, 2021 at 4:48
  • If you run this - is it showing the SelectedFolderPath set to the value you wanted? /usr/bin/default -currentHost read com.apple.ScreenSaverPhotoChooser ... I'm assuming you do have a screensaver activated ??
    – Mr R
    Commented Mar 15, 2021 at 4:51
  • see update......
    – bobsmith76
    Commented Mar 15, 2021 at 8:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .