Toggle screensaver password applescript

November 28th, 2008 § 19 comments

There’s a fix for working on Snow Leopard, just read on MacDuff. Thanks to David and Januz for this!

Recently, I’ve been looking for a script to toggle my screen-saver password for my MacBook.
While out and about I want to make sure my Mac is safe from stray fingers by making sure a password is required before waking, but when at home or in university there’s no need for this extra layer of protection.

Searching the web I found absolutely nothing, except a few scripts that were old and broken.

The only solution; I decided to write my own. You can download the applescript here in zip form (10.6 – Snow Leopard compatible version here), or view the script in your browser here (10.6 – Snow Leopard compatible version here). (Warning – it’s not the easiest thing to read!)

This applescript toggles the screen-saver password, and then displays a growl notification telling you whether the password has been enabled or disabled – handy if you’ve pressed it one time too many and you’re not sure if your screen is locked or not!


If you don’t have growl installed I suggest you download it now from here!

If you’d prefer not to use growl, then just delete the two blocks of code between the
tell application "GrowlHelperApp"
and the next
end tell

I used quicksilver (download it here if you haven’t already!) to create a trigger that means I only have to press a few keys to toggle the password. Works great!

*** Update ***

If you’ve downloaded this script and it isn’t working, it’s probably because you have different settings in your system preferences to me. To find out what yours are open up script editor (found in Applications/Applescript) and run this script

tell application "System Events"
tell security preferences
get properties
end tell
end tell


Hopefully you’ll get a message in the ‘result’ log at the bottom of the script editor. The details in here should match the details on the 3rd line which starts with
if get properties is {require....
except for the first item which should stay as
require password to wake:true,

Enjoy :)

*** Note ***

If you’re logged into a non-admin account, this will ask you for the password every time. Annoying, but hopefully bearable!

Tagged applescript, mac, os x, quicksilver, screensaver, snow leopard

§ 19 Responses to Toggle screensaver password applescript"

  • John says:
    July 21, 2011 at 11:01 pm

    Script still works in Lion 10.7! :) Just assigned a keyboard maestro shortcut to it so I don’t launch it from launchbar anymore

  • phriedrich says:
    April 27, 2011 at 5:38 pm

    Great script, thanks.

    If you only change the lock setting and leave the rest untouched, it also won’t ask for your password:

    set properties to {require password to wake:true}

    and

    set properties to {require password to wake:false}

    If the preference pane is open, the change will not shown immediately, but it still works and after closing and re-opening the preferences the value is shown correctly

  • Brannan Holland says:
    March 25, 2011 at 5:49 am

    I renamed “AppleScript – SSPass” to “password” and it worked great with growl

  • Andreas Kalt says:
    December 29, 2010 at 8:09 pm

    I first didn’t get Growl to work either. Turned out that displaying the script in the browser window there is a problem with the character encoding so that a dash gets turned into some garbled characters.

    See line towards the bottom:

    notify with name "Screensaver Setting" title "Screensaver Setting" description "Passwords have been " & response & "!" application name "AppleScript – SSPass"

    That †after AppleScript should be a dash –

    Fixing that fixed the whole thing. Works fine now on Snow Leopard.

  • John says:
    August 20, 2010 at 7:41 pm

    Getting this in my log when I goto run it, Growl 1.2.1

    21/08/10 6:34:17 AM com.apple.coreservicesd[57] NOTE: Using non-mach-based version of client -> server communication, via direct function calls.
    21/08/10 6:34:17 AM com.apple.coreservicesd[57] NOTE: Using non-mach-based version of client -> server communication, via direct function calls.
    21/08/10 6:34:18 AM com.apple.coreservicesd[57] NOTE: Using non-mach-based version of client -> server communication, via direct function calls.
    21/08/10 6:34:18 AM com.apple.coreservicesd[57] NOTE: Using non-mach-based version of client -> server communication, via direct function calls.
    21/08/10 6:34:18 AM System Preferences[521] .scriptSuite warning for result type of command ‘timedLoad’ in suite ‘SystemPreferences’: the type NSNumber (‘long’) doesn’t match the result Apple event code (‘doub’).
    21/08/10 6:34:19 AM com.apple.launchd[1] (com.apple.netauth.sysagent[463]) Exited with exit code: 255
    21/08/10 6:38:41 AM com.apple.coreservicesd[57] NOTE: Using non-mach-based version of client -> server communication, via direct function calls.
    21/08/10 6:38:41 AM com.apple.coreservicesd[57] NOTE: Using non-mach-based version of client -> server communication, via direct function calls.

  • Patrick says:
    August 20, 2010 at 1:57 pm

    Strange! The only thing I can suggest is trying to remove the AppleScript – SSPass from the Growl pref pane, then running the script again.

    Apart from that, I can only suggest looking for errors in the console or seeing if there’s any info on the Growl forums.

  • John says:
    August 20, 2010 at 11:39 am

    script definately works, and growl is definately installed. in the growl pref pane I can see AppleScript- SSPass. runs with no errors. bizzare.

  • Patrick says:
    August 19, 2010 at 9:40 am

    Still works fine for me on my Snow Leopard installation.

    If you open the script in script editor and run it do you get any errors?
    Just to make sure – you’re on Snow Leopard and have Growl installed! :P

  • John says:
    August 19, 2010 at 9:30 am

    just grabbed the SL script and can’t get growl to work either. any advice?

« Older Comments

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

*

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

What's this?

You are currently reading Toggle screensaver password applescript at Web Design.

meta

  • Author: Patrick
  • Comments: 19 Comments
  • Categories: Mac OS X

  • Pages

    • About Patrick Robertson
    • Bits & Bobs
    • Designing the World
    • Tags
    • Websites
  • Categories

    • Apps (5)
    • Holidays (1)
    • Mac OS X (8)
    • SEO (2)
    • Uncategorized (1)
    • Web Design (4)

© Patrick Robertson 2012

Powered by WordPress