Colorful Playback Widget(Updated)

I made a post a few days ago about this colorful playback widget, but it was wonky and glitchy and ran a python script every second. This new version is much faster, much less CPU intensive, and uses a much better algorithm for approximating the right colors! It works for both Apple Music and Spotify and is super easy to install. If you try it out, let me know what you think :slight_smile: I did a lot of tweaking and testing to get the color approximation right and to get it running on as little processing power as possible.
Here's the download link: Google Drive

this happened when I pasted the script into terminal

touch: ~/Library/Application Support/BetterTouchTool/color.txt: No such file or directory


touch ~/Library/Application\ Support/BetterTouchTool/color.txt

or even

touch "~/Library/Application Support/BetterTouchTool/color.txt"

that first \ is not needed

that said, can't get it to work on BigSur 11.2 Beta (can't get track name or stream name), bur probably a "beta" with Apple Music as a lot of the applescript triggers for it aren't working

1 Like

that worked, thanks.
@Conrad you might want to update the README file.

for Conrad:
I downloaded python 3, refreshed my widgets, did everything the file says, but all I'm getting is this:

Yes, a song is currently playing, so thats not the problem.
I'm using Spotify

Also, in the applescript found under Playing from Music --> Music: Script --> Play/Pause 14th line

should probably change this line

do shell script "sips -Z 30 -o /Users/conradsheehan/Library/Application\\ Support/BetterTouchTool/cover.jpg ~/Library/Application\\ Support/BetterTouchTool/icover.jpg"
do shell script "sips -Z 30 -o '~/Library/Application Support/BetterTouchTool/cover.jpg' '~/Library/Application Support/BetterTouchTool/icover.jpg'"

this will allow it to run under any user as it most of us don't have the '/Users/conradsheehan' user directory

in the meantime, running the applescript(s) throws up these errors

tell application "Music"
get name of current track
--> error number -1728

so we end up with

error "The variable sName is not defined." number -2753 from "sName"

even if your change "name of current track" to "current stream title" in both applescripts (for streamed apple music, not sure for locally hosted files)

so I guess the first question to @Conrad would be, what version of OS X/MacOS are you using (my guess is Catalina?)?

edit: according to

Note: A current bug (or feature) in the Music app (v1.1) prevents AppleScript from getting tag information from a streaming Apple Music track.

He confirms that everything works fine for local tracks, but streamed tracks are NG at the moment

Damn, I should've suspected I would end up leaving a local path in there. This error makes perfect sense, because all tracks on my mac are downloaded, not streamed. However, when using Spotify, the same code: tell application "Spotify" to set sName to (name of current track) worked for songs that were streamed.

strangely enough...suddenly now I can get the track name (but nothing stills shows up in the touch bar)

now running into an iColors is not defined issue....

the sName to (name of current track) works for Spotify, but not for Apple Music (or sometimes works, sometimes doesn't)...happened for awhile in Catalina too...

Unfortunately, this problem is made harder to pin down by the "try, onerror" wrapper that sits around the entire code. Onerror, this code returns the last known "sName", and values of "iColors". iColors wouldn't be defined if anything up to and including the python script failed. You can debug a lot more easily by cutting out this wrapper.

Iā€™m running Big Sur 11.0.1

I think your problem can be fixed by just changing the path as LostInInaka detailed below. You could change it yourself from /Users/conradsheehan/ to ~/Library or you could download it again from Google Drive where I fixed the issue.

This could be because the scaled-down version of the album cover image, (created by sips -z shell cmd) is not present in Application Support/BetterTouchTool/. Or maybe there is a difference in our versions of PIL(python image library).

sorry - edited my reply above...was a stupid error on my part as to why it wasn't working

just trying to figure out the colors part now

This seems like a result of the "sips -z 30" shell command failing. Im using zsh as a default shell. This creates a copy of "icover.jpg" that's scaled down to 30x30 pixels, so you might be processing the entire image.

got it! had to play around with a few of the file locations, etc., but got it working out

in addition to the above...

highly recommend to change the python call to the full path to make sure you are hitting the right python version inside of the applescript (for example, I am using the homebrew version located at /usr/local/opt/python/libexec/bin/python

also for the sips call

do shell script "sips -Z 30 -o ~/Library/Application\\ Support/BetterTouchTool/cover.jpg ~/Library/Application\\ Support/BetterTouchTool/icover.jpg"
(i think this is the same as the original...or very close)

also a bit further down'" & p & "BetterTouchTool/cover.jpg',

which i think originally pointed to icover.jpg instead
only issue I have now is the buttons don't work...but that's a minor issue

Thanks! This is very helpful, it looks like I've been processing the entire image, whoops.

I'll be making the necessary changes to the files on Google Drive, so they should be working fine and needing no further adjustments, for anyone who is interested.

As for your buttons not working maybe its a player prioritization issue(youtube vs apple music), that's my best guess.

I got around the button issue by using applescript instead of the built in calls in BTT

also re: Apple Music....seems if you play a "playlist", the album info is not sent and thus the plugin fails...however, if you play from the "recently added" tab, things work fine...

hopefully apple will get around to fixing this sooner than later...

I hate to be the bearer of bad news but I think I read somewhere that apple cut their automation team a few years ago and stopped fixing bugs. However, I'm optimistic about finding a workaround for this, as its still a pretty versatile framework. I'll look into it.

downloaded the new file, still doesn't seem to work :frowning:

you copied the version I had trouble with....copy the "fixed" version under that

1 Like