Skip to content

Instantly share code, notes, and snippets.

@urchincolley
Created February 23, 2018 19:07
Show Gist options
  • Save urchincolley/8fcb81d6e9f2345e16d7ca0d88ff8215 to your computer and use it in GitHub Desktop.
Save urchincolley/8fcb81d6e9f2345e16d7ca0d88ff8215 to your computer and use it in GitHub Desktop.
#!/bin/bash
APIKEY="Get key from https://api.slack.com/custom-integrations/legacy-tokens and put here"
while true
do
SONG=$(osascript -e 'tell application "Spotify" to name of current track as string')
URLSONG=$(echo "$SONG" | perl -MURI::Escape -ne 'chomp;print uri_escape($_),"\n"')
ARTIST=$(osascript -e 'tell application "Spotify" to artist of current track as string')
URLARTIST=$(echo "$ARTIST" | perl -MURI::Escape -ne 'chomp;print uri_escape($_),"\n"')
curl -s -d "payload=$json" "https://slack.com/api/users.profile.set?token="$APIKEY"&profile=%7B%22status_text%22%3A%22"$URLSONG"%20-%20"$URLARTIST"%22%2C%22status_emoji%22%3A%22%3Anotes%3A%22%7D" > /dev/null
sleep 60
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment