Home

Welcome home, Bluetooth phone owner

(Can’t see the clip?)

Yep, it’s the Just Dropped In Script 2.0 that prepares a Keynote slideshow just for you, and just because it’s good to see you(r Bluetooth phone). Nice, eh?

What your Mac does seconds after you enter your home

  • Displays a bright splash image to make monitor act as lamp
  • Gives you a random compliment
  • Plays a random song from an iTunes playlist
  • Asks a music quiz question while it
  • Prepares a Keynote slideshow that
  • Comments on the actual weather outside and
  • Gives a forecast for tomorrow
  • Checks your GMail
  • Synchronizes your mobile phone over Bluetooth
  • And your iCal calendar
  • Opens Gmail, movie listings, tv listings, feed reader

Digg it
oid1273

To do

  • Display and say iCal appointments for the rest of the day
  • First slide should be so bright that the Mac works like a lamp in a dark appartment
  • Script should not be able to run twice within one hour (save time of last run)
  • Code clean-up (it’s messy in a ‘wow, he’s not even a script kidde’ kind of way)
  • Latest news from RSS sources
  • Any other functionality, really

Want to contribute? Great! Mail me at mortenj (at) genstart.dk and I’ll update the script.

What you’ll need

applescript, ical, bluetooth, phone, smarthome, home automation
If you have an unsaved Keynote presentation while running this script, you will lose it. Forever.

The script is here

set volume to 5

set pathtofiles to “Macintosh HD:Users:mortenjust:Documents:”

set maxmention to 5 –how many email senders should we mention?

set dosaysongtitle to true

set dovideo to true

property dospeak : true

set dolistings to true

set doshowimage to true

set doshowkeynote to true

–set myPlaylist to “Most listened to in the past month”

set myPlaylist to “demo”

set myCompliments to {“You look great.”, “I like your hair.”, “Nice clothes.”}

set myName to “Morten”

set theHour to hours of (current date)

set theMinutes to minutes of (current date)

set i to 0

set rando to random number from 1 to (count of (myCompliments)) as integer

set thisCompliment to item rando of myCompliments

– Yahoo/Weather Channel RSS. This is Copenhagen, Denmark

– http://developer.yahoo.com/weather/

property RSSURL : “http://xml.weather.yahoo.com/forecastrss?p=DAXX0009&u=c”

if not (theHour > 0 and theHour ” & quoted form of RSSFile

set xmlFile to RSSFile

–set titleValue to get value of XML element “title” of XML element “channel” of XML element “rss” of XML file xmlFile

set theWeatherNow to value of XML attribute “text” of XML element “yweather:condition” of XML element “item” of XML element “channel” of XML element “rss” of contents of XML file xmlFile

set theWeatherNowTemp to value of XML attribute “temp” of XML element “yweather:condition” of XML element “item” of XML element “channel” of XML element “rss” of contents of XML file xmlFile

set theForecast to value of XML attribute “text” of XML element 9 of XML element “item” of XML element “channel” of XML element “rss” of contents of XML file xmlFile

set theForecastTempHigh to value of XML attribute “high” of XML element 9 of XML element “item” of XML element “channel” of XML element “rss” of contents of XML file xmlFile

end tell

– Get time

set myTime to theHour & “:” & theMinutes

set myDate to date string of (current date)

– script partially from http://blacktree.cocoaforge.com/forums/viewtopic.php?p=15925&

sid=62bf1d6c41b9dcbdd3cf42be3523f342

set now to current date

set thisMorning to now – (time of now)

set thisEvening to thisMorning + 1 * days – 1

set foundOne to false

set myAppointments to “”

set myTimestring to “”

set myappo to 0

try

tell application “iCal”

– Catch events that start today or that started before today, but have not yet ended.

repeat with thisCalendar in calendars

repeat with thisEvent in ((every event of thisCalendar) whose ((start date ≥ thisMorning and start date ≤ thisEvening) or (end date ≥ now and start date ≤ thisMorning)))

set foundOne to true

tell thisEvent

set theDate to start date

if hours of theDate ≥ hours of now as integer then — i know, this is even more dirty

set myappo to myappo + 1

if (count of events of thisCalendar) > 1 and myappo is not 1 then

set myAppointments to myAppointments & ” and “

end if

set myMinutes to minutes of (theDate)

if myMinutes = 0 then set myMinutes to “”

set myHowlong to hours of (theDate) & ” ” & myMinutes

set myTimestring to ” at ” & myHowlong

set theEventSummary to (summary & myTimestring)

try

set theEventDescription to description

log theEventDescription

on error

set theEventDescription to “something”

end try

set myAppointments to myAppointments & theEventSummary

end if –if hours..

end tell

end repeat

end repeat

end tell

end try

–display dialog myAppointments

– Get mail

set mySenders to “”

tell application “Gmail Notifier”

check for new mail

set myNewmails to (count of entries)

repeat with i from 1 to count of entries

if i is (count of entry) or i is maxmention then

set mySenders to mySenders & ” and “

else if i is not 1 then

set mySenders to mySenders & “, “

end if

set mySenders to mySenders & (author name of entry i as string)

if i is maxmention then

exit repeat

end if

end repeat

end tell

my EditSlide(1, “What a ” & theWeatherNow & ” day! “, ” (” & theWeatherNowTemp & ” degrees if you must know)”)

my EditSlide(2, theForecast, “up to ” & theForecastTempHigh & ” degrees”)

my EditSlide(3, cur_artist, cur_track)

set myTime to (theHour as text) & “:” & (theMinutes as text)

my EditSlide(4, myTime, myDate & ” ” & myAppointments)

my EditSlide(5, (myNewmails as text) & ” new mails”, mySenders)

my startSlideshow()

if (doshowimage) then tell application “QuickTime Player” to quit

my skru_ned()

saythis(“It’s ” & theWeatherNow & ” outside, isn’t it? “)

my NextSlide()

saythis(“Tomorrow is going to be ” & theForecast & ” and up to ” & theForecastTempHigh & ” degrees.”)

my skru_op()

delay 2

my skru_ned()

saythis(“this is”)

my NextSlide()

saythis(cur_artist & ” and their song ” & cur_track)

my skru_op()

– time

delay 1

my skru_ned()

saythis(“it’s now”)

my NextSlide()

if (dospeak) then

saythis(((theMinutes as text) & ” past ” & theHour as text) & ” and you have ” & myappo & ” appointments left for today”)

end if

my skru_op()

–synchronize mobile (or what ever is in isync)

tell application “iSync” to synchronize

my NextSlide()

my skru_ned()

tell application “Gmail Notifier”

check for new mail

set gmails to count of items of entries

my saythis(“You have” & gmails & ” new mails.”)

if (count of entries) > maxmention then

my saythis(“The newest ones are from”)

else if not (count of entries) > maxmention then

my saythis(“from”)

end if

repeat with i from 1 to count of entries

if i is (count of entry) or i is maxmention then

my saythis(“and”)

end if

my saythis(author name of entry i as string)

if i is maxmention then

exit repeat

end if

end repeat

end tell

my skru_op()

–Exit Keynote. No need to save. Hope you don’t have any open documents.

tell application “Keynote”

quit saving no

end tell

–åbn bio, tv, feeds og mail aka stik mig lige avisen

if (dolistings) then

tell application “Safari”

activate

my new_tab()

set the URL of document 1 to “http://www.gmail.com”

my new_tab()

set the URL of document 1 to “http://www.scope.dk/bioliste.php?id=alle&postnummer=1000″

my new_tab()

set the URL of document 1 to “http://www.tvidag.dk”

my new_tab()

set the URL of document 1 to “http://www.bloglines.com/myblogs”

end tell

end if –dolistings

if (dolistings) then

my skru_ned()

saythis(“I have synchronized your phone’s calendar and opened your listings and your mail. It’s a great day!”)

my skru_op()

tell me to activate

display dialog “Would you like to see the listings and your mail?” buttons {“Sure”, “No”} giving up after 300 with title “Good to see you”

if gave up of the result is true or the button returned of the result is “No” then

tell application “Safari” to close document 1

else if the button returned of the result is “Sure” then

tell application “Safari” to activate

end if

end if

end if — human sleep protection

– ———— subs

on new_tab()

tell application “Safari” to activate

tell application “System Events”

tell process “Safari”

click menu item “New Tab” of menu “File” of menu bar 1

end tell

end tell

end new_tab

on skru_ned()

tell application “iTunes”

copy 75 to units

if the volume adjustment of the current track is greater than -255 then

set the volume adjustment of the current track to the (volume adjustment of the current track) – units

end if

end tell

end skru_ned

on skru_op()

delay 1

tell application “iTunes”

copy 75 to units

if the volume adjustment of the current track is greater than -255 then

set the volume adjustment of the current track to the (volume adjustment of the current track) + units

end if

end tell

end skru_op

on EditSlide(s_no, s_title, s_subtitle)

tell application “Keynote”

set the_slide to slide s_no of front slideshow

set the_title to title of the_slide

set the_subtitle to bullet 1 of body of the_slide

set the content of the_title to s_title

set the content of the_subtitle to s_subtitle

end tell

end EditSlide –nextslide

on NextSlide()

try

tell application “Keynote”

activate

end tell

tell application “System Events”

tell process “Keynote”

keystroke “n”

end tell

end tell

on error

beep

end try

end NextSlide

on startSlideshow()

try

tell application “Keynote”

activate

end tell

tell application “System Events”

tell process “Keynote”

tell menu bar 1

click menu item “Play Slideshow” of menu “View”

end tell

end tell

end tell

on error

beep

end try

end startSlideshow

on saythis(thewords)

if (dospeak) then say thewords

end saythis

 
You really should follow me on Twitter. All opinions, spelling mistakes, strategies are mine personally, not the organization I work for.



  1. edge phones Says:

    I found your blog very interesting,just setting mine up.hope it does as well as yours