• 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
Scripting ScreenSaverEngine?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Scripting ScreenSaverEngine?


  • Subject: Scripting ScreenSaverEngine?
  • From: Aaron Solomon Adelman <email@hidden>
  • Date: Mon, 16 Feb 2009 15:23:26 -0500

Greetings.

Off and on I've been tinkering with the idea of creative addition of sound to the Mac OS X user experience.  One thing I've done is write a script that launches a screensaver and then starts playing a random sound (script as it stands now included below).

Problem 1:  Some screensavers are noisy.  I would rather not have music play while a noisy screensaver is running.

Problem 2:  Ideally, I'd like to be able to have specific music play for specific screensavers.

Is there anyway to use AppleScript or an AppleScript-shell script combination to get info on which screensaver is running?  Thanks in advance for any help anyone can provide.

Aaron


The script:

   with timeout of 600 seconds
    try
    set the sound_folder to (path to library folder from user domain as  

- Ignored:
   text) & "Screen Saver Sounds" as alias
    on error err_msg number err_num
    if err_num is -43 then
    do shell script "mkdir ~/Library/Screen\\ Saver\\ Sounds"
    do shell script "ln -s /Library/Audio/Apple\\ Loops/Apple/iLife\\  
   Sound\\ Effects/Jingles ~/Library/Screen\\ Saver\\ Sounds/Jingles"
    do shell script "open ~/Library/Screen\\ Saver\\ Sounds"
    set ignored_result to display alert "A \"Screen Saver Sounds\"  
   folder has been created in the Library folder of your home directory."  
   message "Fill it with sound files movie files, folders of sound or  
   movie files, or aliases to these, and Screen Saver with Music will  
   play one every time it is launched."
    set the sound_folder to (path to library folder from user domain as  
   text) & "Screen Saver Sounds" as alias
   
    else
    beep
    say "Error number " & err_num & ":  " & err_msg
    end if
    end try
   
    try
    tell application "Finder"
    set enchilada to entire contents of the sound_folder
   
    set no_items to count the items of enchilada
    set i to random number from 1 to no_items with seed the time of  
   (current date)
   
    set the choice to item i of the enchilada
    repeat
    if the class of the choice is alias file then
    set the choice to the original item of the choice
    else if the class of the choice is folder then
    set the choice to some item of the choice
    else
    exit repeat
    end if
    end repeat
    end tell
   
    tell application "ScreenSaverEngine"
    launch
    end tell
   
    tell application "Finder"
    (* get the properties of the choice*)
    set choice_extension to the name extension of the choice
    open the choice using (path to application "QuickTime Player")
   
    end tell
   
   
    tell application "QuickTime Player"
    set quit when done of the front document to true
    if the choice_extension is in {"mov", "flv", "m4v"} then
    activate
    present front document
    else
    play front document
    end if
   
    end tell
   
   
    on error err_msg number err_num
    beep
    say "Error number " & err_num & ":  " & err_msg
    end try
   end timeout

   -----
   Aaron Solomon Adelman, PhD
   Epidemiologist/statistician/computer expert
   E-mail:  email@hidden
   Blog:  http://weirdthingoftheday.blogspot.com/
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Prev by Date: Re: Generating MP3 Files???
  • Next by Date: Re: Pages & AppleScript
  • Previous by thread: Re: Generating MP3 Files???
  • Next by thread: AppleScript for Mobile
  • Index(es):
    • Date
    • Thread