Ever since I got my 2016 15″ MacBook Pro with Touch Bar, I wanted to have it show one thing: the currently playing track. Today, thanks to the amazing Better Touch Tool and some Apple Script (which I don’t like, but it gets the job done), I finally have that functionality.

It’s really easy:

Open Better Touch Tool and click on the Touch Bar section. Add a widget and select the “Run Apple Script and Show Return Value” option. Click on the “Advanced Configuration” button and paste the relevant Apple Script (see below). Optional: set the Predefined Action to “Open Application / File / Apple Script …” and select iTunes/Spotify: this will always bring iTunes/Spotiy to the foreground when you tap the widget. Optional: set the iTunes/Spotify icon as the widget’s icon (You can right click on the .app bundle, click on “Show Package Contents”, then go to Contents/Resources. The icones are respectively iTunes.icns and Icon.icns, just drag them over their spot in BTT.)

Here is the script for iTunes:

View the code on Gist.

And here is the one for Spotiy:

View the code on Gist.

The only difference between the two is the name of the app in the first if and in the tell statement.