Turn off Sleep and Screen Saver

I am trying to write my first apples script that will set my computer and display sleep and screensaver interval to "never" when I connect an external display. This is what I have so far:
tell application "System Preferences"
launch
set current pane to pane id "com.apple.preference.energysaver"
tell application "System Events"
set value of every slider of tab group 1 of window "Energy Saver" of process "System Preferences" to 50
end tell
set current pane to pane id "com.apple.preference.desktopscreeneffect"
do shell script "defaults -currentHost write com.apple.screensaver idleTime 0"
quit
end tell
The sliders in Energy Saver move, but reset when I open system preferences to check them. The screen saver interval will not change. Why can I not change its interval in the same way as the other two sliders? Any help is greatly appreciated.

I wonder if it's possible to use GUI scripting to change those system preferences that require administrator privileges. Maybe that's the reason why the settings of the Energy Saver window were not saved after you moved the sliders. However you should be able to set the computer sleep time and the display sleep time with the following line of code:
do shell script "pmset -a sleep 3 displaysleep 3" user name "yourusername" password "your_password" with administrator privileges
On the other hand, using GUI Scripting, it should be possible to change the settings of the Desktop & Screen Saver window, since its preferences don't require administrator privileges:
tell application "System Preferences"
activate
delay 1
tell application "System Events"
tell process "System Preferences"
click menu item "Desktop & Screen Saver" of menu 1 of menu bar item "View" of menu bar 1
-- delay 1
set value of value indicator 1 of slider 1 of group 1 of tab group 1 of window "Desktop & Screen Saver" to 360
end tell
end tell
end tell
However, the value of the slider is not saved either when you quit the System Preferences. I don't know why.

Similar Messages

  • Display won't sleep and screen saver won't sart

    I upgraded to the new OS and the display won't sleep and screen saver won't come on. Help please.

    Long shot.
    Do a backup.
    Quit the application.
    In Finder hold down the option/alt key while selecting the Go menu item. Select Library. Then go to Preferences/com.apple.systempreferences.plist. Move the .plist to your desktop.
    Restart the computer, open the application and test. If it works okay, delete the plist from the desktop.
    If the application is the same, return the .plist to where you got it from, overwriting the newer ones.
    If you want to make your user library permanently visible, run the below command in Applications/Utilities/Terminal.
    chflags nohidden ~/Library/
    You will need to do that after any updates.

  • Require a password for sleep and screen saver

    I click the box that is tick it becomes untick but when i close my laptop it ask me to enter my password in and then when i got to system prefferences it shows me the box tick when i unticked it.
    Please help

    Back up all data.
    Quit System Preferences if it's running. Triple-click the line below to select it:
    ~/Library/Preferences/com.apple.screensaver.plist
    Right-click or control-click the highlighted line and select Services ▹ Reveal from the contextual menu. A Finder window should open with a file selected. Move the selected file to the Desktop, leaving the window open. Relaunch System Preferences and test. If there's no change, quit again and put the file you moved back where it was, overwriting the one that may have been created in its place. Otherwise, delete the file you moved.

  • Cannot change sleep and screen saver

    I do not have File Vault activated.
    I have tried all the usual tricks ( as well as the proper method) but once changed and closed the setting reverts to the original setting.
    I have searched Google and many people are having this problem and no-one in Apple seems to care to resolve this issue.

    Step one is to create a new admin user account, log into it, and see if the problem persists.

  • While i was updating my ipod touch it had an error and froze at the apple logo with a loading bar underneath.How do I fix it? Its stuck there,  tried everything, turn off button home screen button even the volume buttons, nothing is working.

    I was updating my ipod touch and the updation had an error and it froze at the apple logo with the loading bar underneath. How do I fix it? I tried the turn off button home screen button and even the volume buttons. I cant get anything to work. Please help me.

    Connect to itunes and retore.

  • When my phone is not plugged into the charger or computer, it will not turn on at all; even though it is not dead. When it's plugged into the computer, it will go to a white screen with a grey apple icon and then it will turn off again and repeat. IOS7

    When my phone is not plugged into the charger or computer, it will not turn on at all; even though it is not dead. When it's plugged into the computer, it will go to a white screen with a grey apple icon and then it will turn off again and repeat. IOS7 and iPhone 5.

    http://support.apple.com/kb/HT1808
    Try this step and if you cannot get your device into recovery mode there is a chance you have a hardware failure and you need to call apple to see what service options you have.

  • I accidently click for a full screen view on Firefox and now I can't undo it. My bar with tools, bookmarks, etc. is not visible. As the browser opens, the bar appears but then jumps up where it can't be reached. How do I turn off the full screen?

    I accidently clicked for a full screen view on Firefox and now I can't undo it. My bar with tools, bookmarks, etc. is not visible. As the browser opens, the bar appears but then jumps up where it can't be reached. How do I turn off the full screen without access to view options?

    Co-el, This wasn't possible as there wasn't a navigation bar available. The F11 did the trick though. Thanks for adding to the discussion.

  • My iphone 4s automatically getting turned off (blank black screen) and not getting started until full battery discharge, after updating to ios 8.0.1

    My iphone 4s automatically getting turned off (blank black screen) and not getting started until full battery discharge. Even on long pressing power button - screen doesn't showing anything - not even "needs charging logo".
    This is happening only since I have updated to new ios version (ios 8.1).
    Is there anyone facing similar issue?? Any suggestion?!?

    Hi jayla_mora, 
    Thanks for visiting Apple Support Communities. 
    It sounds like your iPhone screen is going blank and not responding. 
    You may find the tips in this article useful for troubleshooting this behavior:
    iOS: Not responding or does not turn on - Apple Support
    Best Regards,
    Jeremy

  • I accidentally turned off bluetooth and now my keyboard won't connect. I already tried to reboot the computer. I can't use the mouse because I ca't get past the user log-in screen. Please help

    I accidentally turned off bluetooth and now my keyboard won't connect. I already tried to reboot the computer. I can't use the mouse because I ca't get past the user log-in screen. Please help

    http://www.cultofmac.com/247979/whoops-reconnect-your-bluetooth-keyboard-and-mac -after-logging-out-os-x-tips/
    had the same problem and it worked!

  • LENOVO G400 TURN OFF AUTOMATICALLY AND NOT LOAD BIOS SETUP

    i have a lenovo g400, once i turn on it only the lenovo name appears in the screen and then it turn off automatically and then turn on and turn off again and so on... also I was having problem that my Lenovo G400 laptop did not display Press F2 to Enter Setup during the boot process, and because of this, no amount of hammering the F2 button would allow access to the BIOS.  I attempted all of the standard fixes, pulled the battery, held power down for 30 seconds, removed the HDD -- nothing would cause this to appear. i dont know whats the problem of my laptop..please help me to fix it..

    hi PRAY2431,
    Welcome to the Lenovo Forums.
    Can you try to access the BIOS by pressing the OneKey Recovery button.
     - Link to picture
    If you manage toget in, try prssing F9 to reload factory defaults then press F10 to save and exit (this should reset the hardware configuration of the machine).
    If you still can't get into the BIOS and the machine still turns off after POST (lenovo screen) then there's likely a hardware component that's failing. If you have a spare PC, try to create a Lenovo Bootable USB Diagnostics and boot from it by pressing F12.
    Alternatively, you can contact Lenovo (for service) or contact one of the Lenovo Authorized Service centers below
    Service Provider List (Philippines)
    Regards
    Did someone help you today? Press the star on the left to thank them with a Kudo!
    If you find a post helpful and it answers your question, please mark it as an "Accepted Solution"! This will help the rest of the Community with similar issues identify the verified solution and benefit from it.
    Follow @LenovoForums on Twitter!

  • Turning off 'Sleep' in Restoring mode

    I'm recovering from a bad crash.  I'm in the process of restroing my computer from a time machine backup on a netword drive, but the screen dims and the computer goes to sleep every half and hour or so.  The time remaining is 51 hours, 48 minutes.  Is there some hidden way to make it NOT go to sleep... because eventually I am going to have to!

    This website tells you how to turn off sleep through terminal commands. Be sure to type in everything AS IS so that you don't accidentally do something bad. Hope this helps you.
    note: the easiest way to do this is to start off your recovery partition or internet recovery, if you're not able to fully boot into your os

  • Airplay streaming stops when you turn off the iPad screen

    Hi All,
    If you are streaming something from your iPad using Airplay, and you hit the button to turn off the iPad screen, it seems that the streaming stops...
    Is there any way to fix that?  I mean, if you are watching a long video, for example, you don't want your iPad to remain on the whole time.
    Any advice?
    - Thanx
    - Jon

    Jon-
    You are saying the AirPlay App does not work when the iPad goes to sleep.  Other Apps do, including the Music App, so you might expect AirPlay to work as well.
    Another limit may be the timer setting at Settings-General-Auto Lock.  Mine is set to 5 Minutes by default.  You may need to set yours to Never, to keep the iPad from sleeping while streaming.
    I suggest you provide feedback to Apple at <iPad Feedback>.
    Fred

  • My Ipad turns off programs and goes back to startpage.

    I have an iPad ( 1 ) the oldest type. It has always got the last upgrade of iOS but more and more often my iPad turns off programs and goes back to startpage of iPad.
    What can I do ?

    1. Double-click the Home button to close all Inactive Apps in Task Bar
    2. Hold the Apps in Task Bar down for a second or two until you see the minus sign
    3. Tap the minus sign to close App
    4. Tap center of screen to return to Home Screen
    5. Reset iPad. Hold the Sleep and Home button down for about 10 second until you see the Apple logo. Ignore the red slider

  • How do you turn off sleep

    I just got an iPad 3 today and used it to post a recipe I could refer to while cooking.  But it kept going to sleep. understandably to reduce battery usage.   I've looked for a control to turn off sleep but do not see one.   I'd settle for just touching the screen to wake it up. but now I have to press the button and do a swipe to bring it back  (with sticky fingers)

    Learn to like it even more.
    The User Guide is available at http://support.apple.com/manuals/ or downloadable from iTunes as an iBook.

  • Iphone 4 turns off randomly and unable to turn it on without charger

    iphone 4 turns off randomly and unable to turn it on without connecting to charger or PC

    Hey Tiffy6996!
    I have an article here for you that describes this issue and can help you troubleshoot the issue a little further:
    iPhone: Hardware troubleshooting
    http://support.apple.com/kb/ts2802
    Will not turn on, will not turn on unless connected to power, or unexpected power off
    Verify that the Sleep/Wake button functions. If it does not function, inspect it for signs of damage. If the button is damaged or is not functioning when pressed, seek service.
    Check if a Liquid Contact Indicator (LCI) is activated or there are signs of corrosion. Learn about LCIsand corrosion.
    Connect the iPhone to the iPhone's USB power adapter and let it charge for at least ten minutes.
    After at least 30 minutes, if:
    The home screen appears: The iPhone should be working. Update to the latest version of iOS if necessary. Continue charging it until it is completely charged and you see this battery icon in the upper-right corner of the screen . Then unplug the phone from power. If it immediately turns off, seek service.
    The low-battery image appears, even after the phone has charged for at least 20 minutes: See "iPhone displays the low-battery image and is unresponsive" symptom in this article.
    Something other than the Home screen or Low Battery image appears, continue with this article for further troubleshooting steps.
    If the iPhone did not turn on, reset it while connected to the iPhone USB power adapter.
    If the display turns on, go to step 4.
    If the display remains black, go to next step.
    Connect the iPhone to a computer and open iTunes. If iTunes recognizes the iPhone and indicates that it is in recovery mode, attempt to restore the iPhone. If the iPhone doesn't appear in iTunes or if you have difficulties in restoring the iPhone, see this article for further assistance.
    If restoring the iPhone resolved the issue, go to step 4. If restoring the iPhone did not solve the issue, seek service.
    Thanks for coming to the Apple Support Communities!
    Cheers,
    Braden

Maybe you are looking for