Display the currently playing track in iTunes/Spotify on the Touch Bar

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:

  1. Open Better Touch Tool and click on the Touch Bar section.
  2. Add a widget and select the “Run Apple Script and Show Return Value” option.
  3. Click on the “Advanced Configuration” button and paste the relevant Apple Script (see below).
  4. 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.
  5. 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:

And here is the one for Spotiy:

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

Better Touch Tool hides the widget if the Apple Script returns nothing (which is the case when the music is paused or when the iTunes/Spotify are closed): you can work that around by replacing the two return "" with return " ", i.e. returning a space when nothing is playing. It’s not very aesthetically pleasing on the Touch Bar because the button is asymmetric, but you can do that if you prefer it that way.

19 thoughts on “Display the currently playing track in iTunes/Spotify on the Touch Bar

  1. Grazie per gli ottimi script…. D’altronde bisogna aggiustarsi con BTT dal momento che praticamente nessuna App si sta adattando alla nuova TB…

  2. Pingback: EasyApple #297: L'utilizzatore di giga - EasyPodcast

  3. Great tip.

    If I press the cross to the left of the widget, it disappears. I find that I have to go into “advanced configuration” and press save, then it’s back.

    Is there a better way of restoring the widget if closed? Or perhaps set it up permanently?

    • That’s a feature of BTT, as it allows you to dismiss its custom Touch Bar to reveal the system/app one. You can however define a shortcut in BTT that launches the action “Toggle BetterTouchTool Touch Bar” to quickly show/hide it.

  4. Pingback: How to display iTunes or Spotify now playing on a Mac TouchBar

  5. hello, when I put the script in, and run script. after which I save but when I look one touch bar it just says the name ‘script:spotify’

    any help?

  6. Is there anything I can do to limit the number of characters shown on that display? If a song name’s a bit longer than usual it takes up the entire touch bar.

  7. The widget worked normally for while, but now it stops displaying the song that is actually playing. It doesn’t display the current song anymore, and is stuck on this song that has been already played 3/4 hours ago. Any help? Thanks!

  8. Thanks a lot for this. One of those times where there is actually an application for the TouchBar and Spotify devs are not taking advantage,

  9. I’ve tried to merge iTunes and Spotify playing together:

    if application “iTunes” is running then
    tell application “iTunes”
    if player state is playing then
    return (get artist of current track) & ” – ” & (get name of current track)
    else if application “Spotify” is running then
    tell application “Spotify”
    if player state is playing then
    return (get artist of current track) & ” – ” & (get name of current track)
    return “”
    end if
    end tell
    end if
    end tell
    return “”
    end if

  10. Hello,
    That is what I’ve been looking for, thanks for the article.

    I have critical questiosn though. When I add widget with itues(or whichever), it starts displaying but It stops displaying after I press button “X” which is displayed before ESC. and after that I need to to save widget again to see current track.
    my touchbar have following buttons:
    (X) ESC itunes-playing track touchbar controls.

    Is there any way to get rid of (X) and always see currently playing track all the time regardless of application?

    I have widget in global settings

    • That’s the expected behavior: the “X” closes BTT’s custom TouchBar.
      I set a shortcut in the Keyboard section of the app that allows me to quickly open it back as needed.
      You have to look for the “Toggle BetterTouchTool Touch Bar” action, which I mapped to ^⇧T.

Leave a Reply

Your email address will not be published. Required fields are marked *