Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

pinyourwings22

macrumors member
Original poster
Aug 20, 2008
30
0
Ohio
As a newer user to the Messages application on Mountain Lion, I wanted to get the current Spotify track to display on my status(as opposed to iTunes), but couldn't find any readily available code. Once I got it working, I figured there would be others like me so I wanted to provide my code :)

Code:
on idle
	tell application "Spotify"
		set theTrack to current track
		set theArtist to artist of theTrack
		set theName to name of theTrack
		if player state is playing then
			set playStatus to "playing"
		else
			set playStatus to "notPlaying"
		end if
	end tell
	
	tell application "Messages"
		if status is available then
			if playStatus is "playing" then
				if (theArtist as string) is not "Spotify" then
					set status message to ("♫ Playing in Spotify: " & (theArtist as string) & " - " & (theName as string))
				end if
			else
				set status message to "Available"
			end if
		end if
	end tell
	
	return 5
end idle

Basically, it checks every 5 seconds to see which track is playing and posts it to your available status on Messages. If Spotify is paused, it changes it back to "Available".

If this is not the correct forum to post this, please kindly redirect me :)

Enjoy!
 
I cannot get this to work, but then again I am a complete novice when it comes to Applescript. I would just like to be able to get this script to work. Help?
 
I cannot get this to work, but then again I am a complete novice when it comes to Applescript. I would just like to be able to get this script to work. Help?

Yeah it's pretty simple, just open up AppleScript Editor, paste this code in, go to File > Export... File Format: Application, Options: Stay open after run handler.

Now you can just open the application you created. When running Spotify and Messages, the status will update with your current song.

hope this helps!
 
Awesome script. Thanks a lot for posting this, I've always wanted to be able to do this. Question though, do you think it would be possible to make this selectable from the status menu in the Messages buddy list and not have to have a dock icon open?
 
Awesome script. Thanks a lot for posting this, I've always wanted to be able to do this. Question though, do you think it would be possible to make this selectable from the status menu in the Messages buddy list and not have to have a dock icon open?

Not really sure, to be quite honest I'm a pretty new to AppleScript. My guess is that you would have to make it run in the background somehow or integrate directly with the Messages application(which I have no clue if that's even possible).

I'll take a look into it, but please post the solution if you have any luck finding one :)
 
Add this to the info.plist file, and the AppleScript shouldn't show up
in the Dock:

<key>NSUIElement</key>
<string>1</string>
 
As a newer user to the Messages application on Mountain Lion, I wanted to get the current Spotify track to display on my status(as opposed to iTunes), but couldn't find any readily available code. Once I got it working, I figured there would be others like me so I wanted to provide my code :)

Code:
on idle
	tell application "Spotify"
		set theTrack to current track
		set theArtist to artist of theTrack
		set theName to name of theTrack
		if player state is playing then
			set playStatus to "playing"
		else
			set playStatus to "notPlaying"
		end if
	end tell
	
	tell application "Messages"
		if status is available then
			if playStatus is "playing" then
				if (theArtist as string) is not "Spotify" then
					set status message to ("♫ Playing in Spotify: " & (theArtist as string) & " - " & (theName as string))
				end if
			else
				set status message to "Available"
			end if
		end if
	end tell
	
	return 5
end idle

Basically, it checks every 5 seconds to see which track is playing and posts it to your available status on Messages. If Spotify is paused, it changes it back to "Available".

If this is not the correct forum to post this, please kindly redirect me :)

Enjoy!


Thank you oh so very much for this code :)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.