Our Blog

Let us find tech solutions together

Jul 15

Control Spotify from Launchbar on Mac OSX

By kinabalu | Comments

 

EDIT: Follow this link for the latest scripts which utilize Spotify’s more enhanced Applescript support

If you’ve been following the latest invite craze, the latest one has to be for the European import Spotify. Basically millions of tracks you can play instantly on your computer for free + ads, and for a fee they’ll remove the ads, and an additional fee they’ll let you stream their catalog from your mobile phone (iPhone or Android). I don’t have any more invites, but I know a lot of folks have had success putting their email in for @amanda. And of course, visit here to download the Spotify client.

If you’re a user of Launchbar or Quicksilver, these Applescripts (for Launchbar) placed in ~/Library/Application Support/LaunchBar/Actions/Spotify should help in controlling your music playing without having to constantly open Spotify. For updates and the original author of these scripts visit this blog article. After adding these applescripts activate Launchbar and select the Index menu > Update Index > All Rules. Or just activate Launchbar and press Cmd-0.

Spotify - Next Song

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
tell application "System Events"
	set MyList to (name of every process)
end tell

tell application "System Events" to set appList to ¬
	name of application processes whose frontmost is true

set activeApp to item 1 of appList
if (MyList contains "Spotify") is true then
	tell application "Spotify" to activate
	tell application "System Events"
		tell process "Spotify"
			click menu item 3 of menu 1 of menu bar item 6 of menu bar 1
		end tell
	end tell
	tell application "System Events"
		set visible of process "Spotify" to false
	end tell
end if

Spotify - Previous Song

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
tell application "System Events"
	set MyList to (name of every process)
end tell

tell application "System Events" to set appList to ¬
	name of application processes whose frontmost is true

set activeApp to item 1 of appList
if (MyList contains "Spotify") is true then
	tell application "Spotify" to activate
	tell application "System Events"
		tell process "Spotify"
			click menu item 4 of menu 1 of menu bar item 6 of menu bar 1
		end tell
	end tell
	tell application "System Events"
		set visible of process "Spotify" to false
	end tell
end if

Spotify - Play/Pause

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
tell application "System Events"
	set MyList to (name of every process)
end tell

tell application "System Events" to set appList to ¬
	name of application processes whose frontmost is true

set activeApp to item 1 of appList
if (MyList contains "Spotify") is true then
	tell application "Spotify" to activate
	tell application "System Events"
		tell process "Spotify"
			click menu item 1 of menu 1 of menu bar item 6 of menu bar 1
		end tell
	end tell
	tell application "System Events"
		set visible of process "Spotify" to false
	end tell
end if

Searching in Spotify

Searching is vital to using this new tool for us folks over here in the United States, and our European brethren have been busy with helpers like searching Spotify with Quicksilver. I liked this so much, I’ve adapted the instructions for Launchbar:

  1. Activate Launchbar and select Index > Show Index or Option+Cmd+I
  2. Browse to Search Templates (UTF-8) and click Add
  3. Add the following entries:
    • Name: Search Spotify for Album Detail: spotify:search:album:*
    • Name: Search Spotify for Artist Detail: spotify:search:artist:*
    • Name: Search Spotify for Song Detail: spotify:search:title:*
  4. Update Index for Search Templates (UTF-8) or All

If using Spaces

Some folks have reported that when using Spaces in OSX the Applescripts have switched to that Space. Simplest thing to do is set the preferences for Spaces so that Spotify shows up on “Every Space”.

Enjoy the music!

EDIT: Follow this link for the latest scripts which utilize Spotify’s more enhanced Applescript support