Wednesday, September 18, 2019

#1 2019-09-11 04:06:27 am

wolfferine
Member
Registered: 2019-09-10
Posts: 2

SetUp/Configuring Screensaver

Hi,

I am new to AppleScript, and as part of trying to set defaults for new account(s), i am trying to set the default screensaver via Applescript.

1. Set default screensaver
2. Set Hot corners (topright = disable the screensaver & bottomright = enable it)
3. Start After = 5 minutes
4. Enable "Show with clock"

Thanks to MacScripter I already found out to do #1 big_smile
Now i need to find how to accomplish the other ones.

I used to use default writes (plist) but as Apple changes a lot when new versions are coming, i decided that it may be saver to probably use AppleScript, but any advice is welcome

Regards
CWolf


Filed under: applescript, screensaver

Offline

 

#2 2019-09-11 07:27:58 am

Nigel Garvey
Moderator
From:: Warwickshire, England
Registered: 2002-11-20
Posts: 5005

Re: SetUp/Configuring Screensaver

Hi wolfferine. Welcome to MacScripter.

Officially, there are System Events settings for #3 and #4. They weren't working when I last looked in macOS 10.13.1, but seem to be working in Mojave:

Applescript:

tell application "System Events"
   set delay interval of screen saver preferences to 5 * minutes
   set show clock of screen saver preferences to true
end tell

Or:

Applescript:

tell application "System Events"
   tell screen saver preferences to set {delay interval, show clock} to {5 * minutes, true}
end tell

Apart from 'main screen only', other settings still have to be done with "defaults write" (or manually in System Preferences), I'm afraid.


NG

Offline

 

#3 2019-09-11 11:32:16 am

wolfferine
Member
Registered: 2019-09-10
Posts: 2

Re: SetUp/Configuring Screensaver

Hi Nigel,

Worked like a charm! Thank you very much, saved me a  lot of valuable time.
Cause i already spent about 2 days googling for something where i could find an answer.
I even tried Automator, as some suggested (copy pasting it to Applescript - but way to much i could, yet, make sense of sad )

Do you, by any chance, know where to find more info about what Applescript can set/configure regarding System Preferences (like the Dock, Trackpad/Mouse, etc..)

BTW - i know/found: The Quick Guide to unScripted Articles

Thanks in advance.
Charles

Last edited by wolfferine (2019-09-11 11:40:17 am)

Offline

 

#4 2019-09-11 02:36:52 pm

Nigel Garvey
Moderator
From:: Warwickshire, England
Registered: 2002-11-20
Posts: 5005

Re: SetUp/Configuring Screensaver

wolfferine wrote:

Do you, by any chance, know where to find more info about what Applescript can set/configure regarding System Preferences (like the Dock, Trackpad/Mouse, etc..)


Hi Charles.

There are a few other preferences that can be set using System Events (a scriptable background application), but they're not particularly comprehensive. There are groups of commands to set preferences (or get information about) accounts, appearance, CD & DVD settings, the Dock, log-in items, network, screen saver etc. etc. If you open System Events's "dictionary" in Script Editor (File -> Open Dictionary …), choose the "View terminology suites" view, and scroll through the list of Suites on the left, you may find a few useful or interesting possibilities.

Otherwise one has to resort to the black arts of running "defaults write" shell scripts or using GUI Scripting (another facility provided by System Events) to imitate clicking things in the System Preferences application. System Preferences itself is scriptable up to the point where you can usually open the view you want, but actually clicking or changing anything in that view requires GUI Scripting.

The disadvantages of "defaults write" are that you have to know what value to write to which key in which domain — which Apple doesn't make easy — and settings may be moved or ignored in later OS versions. The disadvantages of GUI scripting are that the architecture of the windows in you want to click or set things can vary from system to system — and even from user to user if they've set different viewing preferences. But both can be useful from the point-of-view of getting things done, which is what scripting's about.  smile


NG

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)