You can have this run automatically on your mac using the native launchd system if you want ...(see the spotify_song.sh
file below). Or just start it manually to share what you're listening to. 🤷🏼♂️
Drop the following PLIST into ~/Library/LaunchAgents/com.user.slack-spotify.plist
:
The filename must match the string under Label, replace /PATH/TO/SCRIPT.sh with an actual path to the .sh script above.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.user.slack-spotify</string>
<key>ProgramArguments</key>
<array><string>/PATH/TO/SCRIPT.sh</string></array>
<key>RunAtLoad</key>
<true/>
<key>StartInterval</key>
<integer>60</integer>
</dict>
</plist>
Since this also runs on its own timer, remove the following 3 lines from the .sh script:
while true; do
sleep 60
done
Register this daemon with launchd by running
launchctl load ~/Library/LaunchAgents/com.user.slack-spotify.plist
start it by either logging out and back in or running
launchctl start com.user.slack-spotify