Skip to content

Instantly share code, notes, and snippets.

@rdammkoehler
Last active April 10, 2018 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rdammkoehler/f9ded8e8ddfe89e67626 to your computer and use it in GitHub Desktop.
Save rdammkoehler/f9ded8e8ddfe89e67626 to your computer and use it in GitHub Desktop.
Update Slack with my iTunes Track
#!/bin/bash
state=`osascript -e 'tell application "iTunes" to player state as string'`
if [ $state == 'playing' ];
then
artist=`osascript -e 'tell application "iTunes" to artist of current track as string'`
track=`osascript -e 'tell application "iTunes" to name of current track as string'`
message="$USER is listening to $track by $artist"
payload="payload={\"channel\": \"#radio\", \"username\": \"webhookbot\", \"text\": \"$message\", \"icon_emoji\": \":imp:\"}"
curl -X POST --data-urlencode "$payload" {{ slack hook url }} . # https://api.slack.com/incoming-webhooks
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment