• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: lock the screen from the keyboard, win a prize
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: lock the screen from the keyboard, win a prize


  • Subject: Re: lock the screen from the keyboard, win a prize
  • From: Simon Kornblith <email@hidden>
  • Date: Fri, 22 Nov 2002 20:50:40 -0500

On 11/22/02 5:31 PM, "John Delacour" <email@hidden> typed away on
his (or her or its) keyboard producing the following output:

> At 1:34 pm +0000 22/11/02, Nigel Smith wrote:
>
>> Bring on the improvements!
>
>
> set dir to "/Library/Preferences/ByHost/" -- sic
> set ss to "/System/Library/Frameworks/ScreenSaver.framework/"
> set ss to ss & "Versions/A/Resources/ScreenSaverEngine.app"
> set f to dir & (do shell script "cd ~" & dir & ";ls | grep eensav")
> do shell script "perl -e'$f = qq~$ENV{HOME}" & f & "~; open F, $f; $_ = <F>;
> s~ger>0</int~ger>1</int~ ; open F, qq~>$f~; print F' ; open " & ss
> delay 5
> do shell script "perl -e '$f = qq~$ENV{HOME}" & f & "~; open F, $f;
> $_ = <F> ; s~ger>1</int~ger>0</int~ ; open F, qq~>$f~; print F'"

on replaceChars(this_text, search_string, replacement_string)
set AppleScript's text item delimiters to the search_string
set the item_list to every text item of this_text
set AppleScript's text item delimiters to the replacement_string
set this_text to the item_list as string
set AppleScript's text item delimiters to ""
return this_text
end replaceChars

set lf to ASCII character 10
-- Change user's prefs to lock screen
set posixFile to do shell script "ls
~/Library/Preferences/ByHost/com.apple.screensaver.*.plist"
set theFile to POSIX file posixFile
set oldFile to read theFile
if oldFile contains "<key>askForPassword</key>" then
set newFile to replaceChars(oldFile, "<key>askForPassword</key>" &
(ASCII character 10) & " <integer>0</integer>",
"<key>askForPassword</key>" & (ASCII character 10) & "
<integer>1</integer>")
if newFile is not oldFile then
set fp to open for access theFile with write permission
set eof fp to 0
write newFile to fp
close access fp
end if
else
set newFile to replaceChars(oldFile, "<dict>", "<dict>" & (ASCII
character 10) & " <key>askForPassword</key>" & (ASCII character 10) & "
<integer>1</integer>")
set fp to open for access theFile with write permission
set eof fp to 0
write newFile to fp
close access fp
end if
-- Run screen saver
do shell script
"/System/Library/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngin
e.app/Contents/MacOS/ScreenSaverEngine"
-- Set prefs back when we're finished
if oldFile is not newFile then
set fp to open for access theFile with write permission
set eof fp to 0
write oldFile to fp
close access fp
end if

(I sent this in yesterday; it seems, however, that he found the tip for how
to lock from the menubar and no longer cares)

Simon
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: lock the screen from the keyboard, win a prize
      • From: Philip Aker <email@hidden>
References: 
 >Re: lock the screen from the keyboard, win a prize (From: John Delacour <email@hidden>)

  • Prev by Date: Re: lock the screen from the keyboard, win a prize
  • Next by Date: Re: XML-RPC, authentication possible? if not alternative options?
  • Previous by thread: Re: lock the screen from the keyboard, win a prize
  • Next by thread: Re: lock the screen from the keyboard, win a prize
  • Index(es):
    • Date
    • Thread