Skip to content

Instantly share code, notes, and snippets.

@itspriddle
Created July 29, 2009 05:38
Show Gist options
  • Save itspriddle/157887 to your computer and use it in GitHub Desktop.
Save itspriddle/157887 to your computer and use it in GitHub Desktop.
create an entry in ~/.netrc for your twitter username/password:
machine twitter.com
login myusername
password mypassword
(* Check if iTunes is running and grab current song / artist / album *)
tell application "System Events"
if exists process "iTunes" then
tell application "iTunes"
if player state is playing then
set current_song to (name of current track) as Unicode text
set current_artist to (artist of current track) as Unicode text
if current_artist is equal to "" then set current_artist to "Unknown"
set music_playing to "♫ " & current_song & " - " & current_artist
end if
end tell
else
if button returned of (display dialog "iTunes isn't running" & return & "" buttons {"Wait", "Quit"}) is "Quit" then quit
end if
end tell
set the_status to quoted form of ("status=" & music_playing)
try
do shell script "curl -n -d " & the_status & " https://twitter.com/statuses/update.xml --insecure"
on error
open location "x-launchbar:large-type?string=There+was+an+error+sending+your+tweet.+Please+try+again."
end try
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment