Last active
April 10, 2018 14:08
-
-
Save rdammkoehler/f9ded8e8ddfe89e67626 to your computer and use it in GitHub Desktop.
Update Slack with my iTunes Track
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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