hmm time to rid the world of Massive Attack and Hot Chip with a launch agent (watch paths obviously) and this script. My App is called KMix :)
#!/bin/bash
# Process Check to see if Spotify is running
if ps aux | grep -v grep | grep Spotify.app
then
# Specify to run it as an OS applesctipt specifying it ends at EOT
/usr/bin/osascript <<EOT
# Get the current track
tell application "Spotify"
set theTitle to name of the current track
set check to artist of current track
# If the track is Lebanese Blonde then skip it
if theTitle is "Lebanese Blonde" then
play (next track)
end if
# If its crap Hot Chip then skip it
if check is "Hot Chip" then
do shell script "open /Applications/KMix.app"
end if
# If its Massive attack then skip it
if check is "Massive Attack" then
do shell script "open /Applications/KMix.app"
end if
# If its that annoying track skip it
if theTitle is "Testify" then
do shell script "open /Applications/KMix.app"
end if
end tell
EOT
fi
exit 0
One annoying thing is that different departments keep turning down the Spotify volume itself using our ipod remoteless app instead of using our other volume control app iRule.
Time to fix that ;)
with a launch daemon with watchpath to the users spotify cache
and this bash script actually an applescript written in bash... yes that right peeps use this example if you need to run an applescript as a login hook but never worked out how
#!/bin/bash
# Process Check to see if Spotify is running
if ps aux | grep -v grep | grep Spotify.app
then
# Specify to run it as an OS applesctipt specifying it ends at EOT
/usr/bin/osascript <<EOT
# Pause 15 seconds
delay 15
# Set the variable volcheck to get the current sound volume of Spotify
tell application "Spotify"
set volcheck to get sound volume
# If the volume is not up full then turn it up!
if volcheck is not 100 then
set sound volume to 100
end if
end tell
EOT
fi
exit 0
Does anyone know how i can just check the process Spotify?
There is a constant SpotifyWebHelper process running causing it not to be very clean, in otherwords if you quit spotify it opens up again to run the script because of the blasted SpotifyWebHelper.
Can anyone tell me how to exclude this?
changed the scripts above to do a ps aux | grep -v grep | grep Spotify.app so that it wouldn't grep the SpotifyWebHelper ;)
changed my script due to it failing because of the recent web player.
What i did this time is reference a track from a playlist i found on Spotify and stored it in /Users/Shared/tunes.rtf created using vi
(right click track and Copy Spotify URI)
This means when i want to change the music playlist i just change the file contents in /Users/Shared/tunes.rtf
this is what im using at the moment which has some good morning track on there
spotify:user:1137064509:playlist:6FeclgYp45QjvvIEH7f4DS
The App then references this and plays it, skipping to the next track so that it doesn't start with the same one all the time
Have the app open at login
Set the mac to autostartup and login in automatically :)
Got moaned at a bit for blocking tracks :(
try
-- Kill Spotify
do shell script "killall Spotify"
-- Pause 5 seconds
delay 5
-- read the reference file
set tunes to do shell script "cat /Users/Shared/tunes.rtf"
-- Make sure shuffle & repeat is on
tell application "Spotify"
if shuffling is false then
set shuffling to true
if repeating is false then
set repeating to true
end if
end if
end tell
delay 1
tell application "Spotify"
activate
set sound volume to 0
play track tunes
next track
delay 6
set sound volume to 100
end tell
-- Bring Spotify to the front
set appName to "spotify"
set startIt to false
tell application "System Events"
if not (exists process appName) then
set startIt to true
else if frontmost of process appName then
set visible of process appName to false
else
set frontmost of process appName to true
end if
end tell
if startIt then
tell application appName to activate
end if
end try