Skip to content

Instantly share code, notes, and snippets.

@bradbaris
Last active January 12, 2018 22:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bradbaris/9ee7911d8f4f6f60bf58c80cd5b79a9e to your computer and use it in GitHub Desktop.
Save bradbaris/9ee7911d8f4f6f60bf58c80cd5b79a9e to your computer and use it in GitHub Desktop.
Sets the current song playing on Spotify to your Slack status
#!/bin/bash
# https://api.slack.com/custom-integrations/legacy-tokens
APIKEY="<INSERT_LEGACY_API_TOKEN>"
while true
do
SONG=$(osascript -e 'tell application "Spotify" to name of current track as string')
ARTIST=$(osascript -e 'tell application "Spotify" to artist of current track as string')
URLSONG=$(echo "$SONG" | perl -MURI::Escape -ne 'chomp;print uri_escape($_),"\n"')
URLARTIST=$(echo "$ARTIST" | perl -MURI::Escape -ne 'chomp;print uri_escape($_),"\n"')
curl -X POST -s -d "payload=$json" "https://slack.com/api/users.profile.set?token="$APIKEY"&profile=%7B%22status_text%22%3A%22"$URLARTIST"%20%2D%20"$URLSONG"%22%2C%22status_emoji%22%3A%22%3Aheadphones%3A%22%7D" > /dev/null
sleep 30
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment