Skip to content

Instantly share code, notes, and snippets.

@spjwebster
Created July 23, 2009 16:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spjwebster/153230 to your computer and use it in GitHub Desktop.
Save spjwebster/153230 to your computer and use it in GitHub Desktop.
-- activate screensaver
tell application "ScreenSaverEngine" to activate
set screensaver_running to true
set away_message to "Gone fishing"
-- pause itunes if running
tell application "System Events" to set iTunesRunning to (number of items in (processes whose name is "iTunes") is greater than 0)
if iTunesRunning then
tell application "iTunes" to pause
end if
-- set adium status and message if running
tell application "System Events" to set AdiumRunning to (number of items in (processes whose name is "Adium") is greater than 0)
if AdiumRunning then
tell application "Adium"
go away with message away_message
end tell
end if
-- set Colloquy status if running
tell application "System Events" to set ColloquyRunning to (number of items in (processes whose name is "Colloquy") is greater than 0)
if ColloquyRunning then
tell application "Colloquy"
repeat with conn in every connection
tell conn to set away message to away_message
end repeat
end tell
end if
-- wait for screen saver to quit
repeat while screensaver_running is true
delay 5
tell application "System Events" to set screensaver_running to (number of items in (processes whose name is "ScreenSaverEngine") is greater than 0)
end repeat
-- restore Adium's state if running
if AdiumRunning then
tell application "Adium"
go available
end tell
end if
-- restore Colloquy's state if running
if ColloquyRunning then
tell application "Colloquy"
repeat with conn in every connection
tell conn to set away message to ""
end repeat
end tell
end if
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment