Open the current user's screensaver timeout either programmatically or via the command line on mac

Does anyone know how to find out what the timeout is for the current user screensaver on a Mac. I would prefer a programmatic method if possible, but I am also happy to analyze the output of the command line utility. I already do this with pmset to get sleep time.

+4
source share
2 answers

The value of the screen saver settings for the current user (at least 10.6.x up) stored in the properties list file in ~/Library/Preferences/com.apple.screensaver.plist. Perhaps there is no value if the user decided to turn off automatic screen blanking / saving.

You can read the value using a command line utility called defaults (1) :

defaults read com.apple.screensaver idleTime
defaults -currentHost read com.apple.screensaver idleTime

The former provides access to the settings of the current user, the latter to system defaults, if one exists.

(1) , . , defaults read com.apple.screensaver idleTime , , . (1) . (1) . , , .

Apple Xcode / .

+4

( El Capitan) , 10.11 , currentHost:

$ defaults read com.apple.screensaver
{
    askForPassword = 1;
    askForPasswordDelay = 5;
    tokenRemovalAction = 0;
}

currentHost:

$ defaults -currentHost write com.apple.screensaver idleTime 60
$ defaults -currentHost read com.apple.screensaver
{
    PrefsVersion = 100;
    idleTime = 60;
    moduleDict =     {
        moduleName = iLifeSlideshows;
        path = "/System/Library/Frameworks/ScreenSaver.framework/Resources/iLifeSlideshows.saver";
        type = 0;
    };
    showClock = 0;
    tokenRemovalAction = 0;
}

write , , . , !

+5

All Articles