-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6e332b4
commit 6a1cf45
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
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
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 |