Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Chaitanya-Shahare committed Oct 13, 2023
1 parent 6e332b4 commit 6a1cf45
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions spotify-notifier.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

# Initialize variables to keep track of the current song
current_song=""
current_artist=""

# Send the initial notification
initial_song_info=$(osascript -e 'tell application "Spotify" to name of current track & " - " & artist of current track')
terminal-notifier -title "Now Playing" -message "$initial_song_info" -group "spotify_notification" -sender com.spotify.client
current_song="$initial_song_info"

# Check for song changes in a loop
while true; do
# Get the current song and artist from Spotify
song_info=$(osascript -e 'tell application "Spotify" to name of current track & " - " & artist of current track')

# Check if the song has changed
if [ "$song_info" != "$current_song" ]; then
# Send or update the notification using terminal-notifier
terminal-notifier -title "Now Playing" -message "$song_info" -group "spotify_notification" -sender com.spotify.client

# Update the current song
current_song="$song_info"
fi

# Sleep for a few seconds before checking again
sleep 10
done

0 comments on commit 6a1cf45

Please sign in to comment.