macos support

This commit is contained in:
2025-04-08 14:44:20 -07:00
parent e3297c7983
commit 0961746560
3 changed files with 55 additions and 4 deletions

22
get-media.sh Executable file
View File

@@ -0,0 +1,22 @@
#!/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"