Hey,
I have made some improvements to your script as it didn't seem to work when playing music offline...
I also reworked the icon update as I noticed that with some artworks it was having trouble updating the icon (i noticed they took a bit longer to be added to the btt folder and therefore it would be take the artwork from the previous song) but now it works 100% of the time
on name_and_cover(trackName, iPath)
tell application "BetterTouchTool"
if iPath contains "offline" then
update_touch_bar_widget "61E02114-40B8-4D7E-94D0-6F0110B7D846" text trackName
else
update_touch_bar_widget "61E02114-40B8-4D7E-94D0-6F0110B7D846" text trackName icon_path iPath
end if
end tell
end name_and_cover
set iconPath to "~/Library/Application Support/BetterTouchTool/spotify_cover.png"
if application "Spotify" is running then
try
tell application "Spotify"
try
set artworkURL to artwork url of current track
do shell script "curl " & artworkURL & " -o ~/Library/Application\\ Support/BetterTouchTool/spotify_cover.png"
on error number 6
set iconPath to "offline"
end try
if player state is playing then
set trackTitle to ((get name of current track) & " - " & (get artist of current track))
if length of trackTitle is less than 27 then
set displayTitle to trackTitle
my name_and_cover(displayTitle, iconPath)
else
set displayTitle to text 1 thru 27 of trackTitle & "..."
my name_and_cover(displayTitle, iconPath)
end if
else
my name_and_cover("(Paused)", iconPath)
end if
end tell
end try
else
return ""
end if