#!/bin/bash # Get the currently playing Spotify track title process_info=$(osascript -e 'tell application "Spotify" to if player state is playing then name of current track & " - " & artist of current track') if [[ -n "$process_info" ]]; then if [[ "$process_info" =~ ^(.*)\ -\ (.*)$ ]]; then artist="${BASH_REMATCH[2]}" songTitle="${BASH_REMATCH[1]}" else artist="Unknown" songTitle="$process_info" fi else artist="" songTitle="" fi # Create JSON output json_output=$(jq -n --arg title "$songTitle" --arg artist "$artist" --arg amUri "" '{title: $title, artist: $artist, amUri: $amUri}') echo "$json_output"