Skip to content

Instantly share code, notes, and snippets.

Created March 27, 2013 19:54
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/5257483 to your computer and use it in GitHub Desktop.
Save anonymous/5257483 to your computer and use it in GitHub Desktop.
An AppleScript that waits for a message to appear in the Mac "Notes" application, then perform an action. An iOS user can use Siri to "Write a note", and then say "What apps are running?" to get a list of all apps running on the Mac, "Shut down" to shut down the Mac, "Go to sleep" to put the Mac to sleep, or "Restart my mac" to restart the Mac. …
on run
-- just here to get things started...
end run
on idle
tell application "Notes"
if exists note "What apps are running?" then
delete note "What apps are running?"
tell application "Finder"
set myRunningApps to name of every process whose visible is true
tell application "Notes"
if exists note "Running Apps:" then
delete note "Running Apps:"
end if
set noteTitle to "Running Apps:"
set AppleScript's text item delimiters to ", "
set appsList to myRunningApps as text
make new note at folder "Notes" with properties {name:noteTitle, body:appsList}
end tell
end tell
else if exists note "Shut down" then
delete note "Shut down"
tell application "Finder" to quit
else if exists note "Go to sleep" then
delete note "Go to sleep"
tell application "Finder" to sleep
else if exists note "Restart my mac" then
delete note "Restart my mac"
tell application "Finder" to restart
end if
end tell
return 1
end idle
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment