# Kashi: Show Current Song Lyrics on Touch Bar (Spotify / iTunes / Youtube)

**URL:** <https://community.folivora.ai/t/kashi-show-current-song-lyrics-on-touch-bar-spotify-itunes-youtube/6301>\
**Category:** Setup/Preset Sharing\
**Tags:** itunes, python, youtube, spotify, touch-bar\
**Created:** [January 17, 2019, 8:48pm UTC](https://community.folivora.ai/t/kashi-show-current-song-lyrics-on-touch-bar-spotify-itunes-youtube/6301 "2019-01-17T20:48:47Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![nemobushido](https://community.folivora.ai/letter_avatar_proxy/v4/letter/n/77aa72/32.png) [@nemobushido](https://community.folivora.ai/u/nemobushido)\
**Post date:** [January 17, 2019, 8:48pm UTC](https://community.folivora.ai/t/kashi-show-current-song-lyrics-on-touch-bar-spotify-itunes-youtube/6301/1 "2019-01-17T20:48:47Z")

</div>

Hi BTT community,

This is my first BTT plugin/preset. Since the community is already so great at making visually pleasing presets, I thought I'd focus on function rather than form. As an audiophile, I wanted my project to be music-related, so I ended up making "Kashi".

**[Kashi](https://github.com/zer8ne/Kashi)** is a widget that display the lyrics of the current song playing on Spotify, iTunes, or Youtube on the Touch Bar. Here are some videos of it in action (may take a minute to load):

**Spotify & iTunes:**

[/uploads/default/original/2X/2/29ecb3ff5d49b6663b0a80f9df11c16a5d66d99f.mp4](https://community.folivora.ai/uploads/default/original/2X/2/29ecb3ff5d49b6663b0a80f9df11c16a5d66d99f.mp4)

**YouTube:**

[/uploads/default/original/2X/d/dcf20d441b4ff5d7ca6265239959c4e5c6176fbe.mp4](https://community.folivora.ai/uploads/default/original/2X/d/dcf20d441b4ff5d7ca6265239959c4e5c6176fbe.mp4)

Set-up is explained in the **[ReadMe](https://github.com/zer8ne/Kashi)**, but basically there are a few Python 3 modules that need to be installed for the widget to work.

Thanks for taking the time to read this!  
All questions and comments are welcome.

---

<div class="post-metadata">

**Author:** ![lithedreamer](https://community.folivora.ai/letter_avatar_proxy/v4/letter/l/f6c823/32.png) [@lithedreamer](https://community.folivora.ai/u/lithedreamer)\
**Post date:** [January 18, 2019, 4:21am UTC](https://community.folivora.ai/t/kashi-show-current-song-lyrics-on-touch-bar-spotify-itunes-youtube/6301/2 "2019-01-18T04:21:16Z")

</div>

@nemobushido Hi I'm super excited to get your preset running. I either get an error on my touch bar that 'false is not defined', easily fixed by changed 'false' to 'False'. After that, the module just doesn't load on the touch bar.

Line: "BTTTouchBarAppleScriptStringRunOnInit"

---

<div class="post-metadata">

**Author:** ![nemobushido](https://community.folivora.ai/letter_avatar_proxy/v4/letter/n/77aa72/32.png) [@nemobushido](https://community.folivora.ai/u/nemobushido)\
**Post date:** [January 18, 2019, 6:20am UTC](https://community.folivora.ai/t/kashi-show-current-song-lyrics-on-touch-bar-spotify-itunes-youtube/6301/3 "2019-01-18T06:20:47Z")

</div>

@lithedreamer  
Just confirming, but have you installed Python 3 and the required dependencies? You may need to install them globally to access them from BTT.

Also, check that the line below points to the proper path where your python3 installation lives.

> **"BTTShellScriptWidgetGestureConfig" : "/usr/local/bin/python3:::-c",**

For debugging, you can execute the script from Terminal and see if it prints the correct lyrics in console:

> _ **python3 kashi.py** _
> 
> or if you are not in the same folder as the script,
> 
> _ **python3 /folderpath/kashi.py** _

Uncomment (delete '#' in front of) certain lines of code to check data flow.

For example you can target the player data,

> **print(player\_data)**

or data from the API response:

> **print("\nHits:", hits)**  
> **print('\nGenius Artist: ' + genius\_artist + '\nGenius Song: ' + genius\_song + '\nGenius URL: ' + genius\_url + '\n')**

If Terminal shows no issue, the widget should simply work by copy pasting the JSON into the settings: [kashi.json](https://community.folivora.ai/uploads/default/original/2X/2/2cff9a5c166984e587fc96a7780d4b2b2ea55a02.json).

---

<div class="post-metadata">

**Author:** ![lithedreamer](https://community.folivora.ai/letter_avatar_proxy/v4/letter/l/f6c823/32.png) [@lithedreamer](https://community.folivora.ai/u/lithedreamer)\
**Post date:** [January 19, 2019, 4:23am UTC](https://community.folivora.ai/t/kashi-show-current-song-lyrics-on-touch-bar-spotify-itunes-youtube/6301/4 "2019-01-19T04:23:41Z")

</div>

Thanks for getting back to me. Testing the print statements: all of them work and dispense the correct lyrics in terminal, which seems to suggest that the python modules are set up correctly (the path for python3 is also correct). Copying and pasting the JSON into the settings seems to create the same result: just blank Touch Bar space, not even a button as far as I can tell.

---

<div class="post-metadata">

**Author:** ![nemobushido](https://community.folivora.ai/letter_avatar_proxy/v4/letter/n/77aa72/32.png) [@nemobushido](https://community.folivora.ai/u/nemobushido)\
**Post date:** [January 19, 2019, 5:17am UTC](https://community.folivora.ai/t/kashi-show-current-song-lyrics-on-touch-bar-spotify-itunes-youtube/6301/5 "2019-01-19T05:17:39Z")

</div>

@lithedreamer  
I see. Then it must be how your bar is set up. Can you make sure that the widget is checked "Visible", item placement is "Scrollable Main Container", and that no other widgets occupy the same space? Having a left and a right one is OK.

Please see below:

 ![14](https://community.folivora.ai/uploads/default/original/2X/0/0534cc136f137f2457f2183ba3cdaec46ef3cafe.jpeg)

---

<div class="post-metadata">

**Author:** ![lithedreamer](https://community.folivora.ai/letter_avatar_proxy/v4/letter/l/f6c823/32.png) [@lithedreamer](https://community.folivora.ai/u/lithedreamer)\
**Post date:** [January 19, 2019, 6:20pm UTC](https://community.folivora.ai/t/kashi-show-current-song-lyrics-on-touch-bar-spotify-itunes-youtube/6301/6 "2019-01-19T18:20:25Z")

</div>

Widget is checked visible and item placement is a Scrollable Main Container. I turned off all my other widgets, so nothing should be interfering...

---

<div class="post-metadata">

**Author:** ![nemobushido](https://community.folivora.ai/letter_avatar_proxy/v4/letter/n/77aa72/32.png) [@nemobushido](https://community.folivora.ai/u/nemobushido)\
**Post date:** [January 20, 2019, 8:46am UTC](https://community.folivora.ai/t/kashi-show-current-song-lyrics-on-touch-bar-spotify-itunes-youtube/6301/7 "2019-01-20T08:46:28Z")

</div>

Hm, I'm a bit stumped. Thanks for your persistence.

Could you try creating the widget from scratch? Create a new "Run Shell Script And Show Return Value" script widget and confirm that it's showing text. Then copy+paste the .py script (Parameter = "-c").

---

<div class="post-metadata">

**Author:** ![shark12349876](https://community.folivora.ai/letter_avatar_proxy/v4/letter/s/a698b9/32.png) [@shark12349876](https://community.folivora.ai/u/shark12349876)\
**Post date:** [January 21, 2019, 1:47am UTC](https://community.folivora.ai/t/kashi-show-current-song-lyrics-on-touch-bar-spotify-itunes-youtube/6301/8 "2019-01-21T01:47:24Z")

</div>

Hello, really great work! I am just having some trouble getting the lyrics to scroll as the song play. If you could help that would be awesome!  
Thanks

---

<div class="post-metadata">

**Author:** ![Bowser](https://community.folivora.ai/user_avatar/community.folivora.ai/bowser/32/6400_2.png) [@Bowser](https://community.folivora.ai/u/Bowser)\
**Post date:** [August 23, 2019, 10:31pm UTC](https://community.folivora.ai/t/kashi-show-current-song-lyrics-on-touch-bar-spotify-itunes-youtube/6301/10 "2019-08-23T22:31:07Z")

</div>

Hi, trying to get this to work and I keep running into this error.

File "kashi.py", line 214, in   
main()  
File "kashi.py", line 20, in main  
player\_data)  
File "kashi.py", line 135, in processPlayerData  
player\_artist = player\_data[1].lower()

IndexError: list index out of range

---

<div class="post-metadata">

**Author:** ![nemobushido](https://community.folivora.ai/letter_avatar_proxy/v4/letter/n/77aa72/32.png) [@nemobushido](https://community.folivora.ai/u/nemobushido)\
**Post date:** [August 24, 2019, 5:51pm UTC](https://community.folivora.ai/t/kashi-show-current-song-lyrics-on-touch-bar-spotify-itunes-youtube/6301/11 "2019-08-24T17:51:53Z")

</div>

Hi Bowser.

Seems like the "player\_data" array is completely empty in your case. That is strange because the "getBrowserAndPlayerData" function should default values to "none" if no player or browser is running.

Which means you must be having problems with the osascript module. It is responsible for running the applescripts which get the player/browser data. Make sure that all osascript and all other Python modules are correctly installed.

The best way to do this is to test the script on command line and see if your Python spits any error about the modules. E.g., you can add the line "print(player\_data)" to see what is in that list.

Also, very important is to make sure your launch path, parameter, and Python path are properly specified. For me, these are:

Launch Path:  
/usr/local/bin/python3

Parameters:  
-c

PYTHONPATH:  
PYTHONPATH=/Library/Frameworks/Python.Framework/Versions/3.7/lib/Python3.7/site-packages

The PYTHONPATH may vary for you depending on how your Python is installed.

---

<div class="post-metadata">

**Author:** ![Bowser](https://community.folivora.ai/user_avatar/community.folivora.ai/bowser/32/6400_2.png) [@Bowser](https://community.folivora.ai/u/Bowser)\
**Post date:** [September 7, 2019, 2:26am UTC](https://community.folivora.ai/t/kashi-show-current-song-lyrics-on-touch-bar-spotify-itunes-youtube/6301/12 "2019-09-07T02:26:45Z")

</div>

I've been trying everything I can think of. I created a new partition and reinstalled osx along with python and the modules. Everything seems to point to the right place. When playing around in idle with the module, it sees the functions and i can call them but it cant see the data. e.g. when I called printWisdom() it recognizes that it needs an input but cant seem to get one

---

<div class="post-metadata">

**Author:** ![nemobushido](https://community.folivora.ai/letter_avatar_proxy/v4/letter/n/77aa72/32.png) [@nemobushido](https://community.folivora.ai/u/nemobushido)\
**Post date:** [September 7, 2019, 4:01am UTC](https://community.folivora.ai/t/kashi-show-current-song-lyrics-on-touch-bar-spotify-itunes-youtube/6301/13 "2019-09-07T04:01:29Z")

</div>

Hi Bowser,

Sorry for the trouble you're going through.

The printWisdom function just prints a music-related quote (static data) if there are no hits from the lyrics API, so it doesn't tell much about your configuration.. The key here is that you can't see the player data. Is the py script able to spit out the player data? Try printing the variable "player\_data" (or "browser\_data" if it's Youtube) after line 17 and see what comes out.

I'm also unsure if your Python is configured correctly with BetterTouchTool. You can test this simply by running a script as simple as **`print("Testing Python")`** and see if it shows up on the bar.

Let me know how it goes! Feel free to post some screenshots too. If you need remote assistance, I don't mind helping you out. Just let me know.

---

<div class="post-metadata">

**Author:** ![gabs0806](https://community.folivora.ai/letter_avatar_proxy/v4/letter/g/ecae2f/32.png) [@gabs0806](https://community.folivora.ai/u/gabs0806)\
**Post date:** [October 28, 2019, 4:37am UTC](https://community.folivora.ai/t/kashi-show-current-song-lyrics-on-touch-bar-spotify-itunes-youtube/6301/14 "2019-10-28T04:37:50Z")

</div>

Any chance for an updated read me for the change from iTunes to music in Catalina

---

<div class="post-metadata">

**Author:** ![Shervin\_Abbasi](https://community.folivora.ai/user_avatar/community.folivora.ai/shervin_abbasi/32/7058_2.png) [@Shervin\_Abbasi](https://community.folivora.ai/u/Shervin_Abbasi)\
**Post date:** [November 16, 2019, 6:51pm UTC](https://community.folivora.ai/t/kashi-show-current-song-lyrics-on-touch-bar-spotify-itunes-youtube/6301/15 "2019-11-16T18:51:40Z")

</div>

I have been getting this error and I'm really confused about it if anyone can help me. I would be appreciated.  
File "", line 35  
"BTTTouchBarShellScriptString": "/usr/bin/python3 -m touchbar\_lyric]”,  
^  
SyntaxError: EOL while scanning string literal

---

<div class="post-metadata">

**Author:** ![happyuturn](https://community.folivora.ai/user_avatar/community.folivora.ai/happyuturn/32/8951_2.png) [@happyuturn](https://community.folivora.ai/u/happyuturn)\
**Post date:** [November 27, 2019, 12:24pm UTC](https://community.folivora.ai/t/kashi-show-current-song-lyrics-on-touch-bar-spotify-itunes-youtube/6301/16 "2019-11-27T12:24:44Z")

</div>

Hi, I'm also getting an error:

Traceback (most recent call last):  
File "", line 202, in   
File "", line 19, in main  
File "", line 130, in processPlayerData  
IndexError: list index out of range

my launch path and parameters are correct per your instructions above. Where do I enter the PYTHONPATH lines? I tried with and without that line in the second paramters input to no avail.

I'm excited for this Preset, any help would be greatly appreciated

thanks

---

<div class="post-metadata">

**Author:** ![nemobushido](https://community.folivora.ai/letter_avatar_proxy/v4/letter/n/77aa72/32.png) [@nemobushido](https://community.folivora.ai/u/nemobushido)\
**Post date:** [November 30, 2019, 8:03pm UTC](https://community.folivora.ai/t/kashi-show-current-song-lyrics-on-touch-bar-spotify-itunes-youtube/6301/17 "2019-11-30T20:03:17Z")

</div>

@gabs0806:

I've cleaned up the README for Catalina and added a new section for configuring parameters as a final step. Hope it helps.

@Shervin_Abbasi:

I think you are looking for [https://pypi.org/project/touchbar-lyric/](https://pypi.org/project/touchbar-lyric/).

@happyuturn:

I updated the path defaults, so please try again with the updated JSON file. Launch Path no longer refers to the environment variable and directly references the install path. Also, "PYTHON=" was not necessary. I updated the README to show this.

---

<div class="post-metadata">

**Author:** ![happyuturn](https://community.folivora.ai/user_avatar/community.folivora.ai/happyuturn/32/8951_2.png) [@happyuturn](https://community.folivora.ai/u/happyuturn)\
**Post date:** [November 30, 2019, 8:35pm UTC](https://community.folivora.ai/t/kashi-show-current-song-lyrics-on-touch-bar-spotify-itunes-youtube/6301/18 "2019-11-30T20:35:24Z")

</div>

> [@nemobushido](#):
>
> I updated the path defaults, so please try again with the updated JSON file. Launch Path no longer refers to the environment variable and directly references the install path. Also, "PYTHON=" was not necessary. I updated the README to show this.

I tried with the new JSON and got Error/Nothing was returned.

I'm running Catalina and installed python3 via homebrew.

My launch path for python3 is /usr/local/bin (determined via running which python3) and my site packages path is /usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages which I entered in the second params line. (I followed the directions here: [How do I find the location of my Python site-packages directory? - Stack Overflow](https://stackoverflow.com/questions/122327/how-do-i-find-the-location-of-my-python-site-packages-directory))

I'm trying with Apple Music. I open Music, start a song then use Run Script Now in the BTT config pane.

Any suggestions on different approaches I can try? Happy to add any debug lines into the python script to help resolve

thanks

---

<div class="post-metadata">

**Author:** ![nemobushido](https://community.folivora.ai/letter_avatar_proxy/v4/letter/n/77aa72/32.png) [@nemobushido](https://community.folivora.ai/u/nemobushido)\
**Post date:** [December 1, 2019, 3:15am UTC](https://community.folivora.ai/t/kashi-show-current-song-lyrics-on-touch-bar-spotify-itunes-youtube/6301/19 "2019-12-01T03:15:02Z")

</div>

@happyuturn  
To be honest, haven't been testing with Music and wonder if it is app-specific.  
Can you confirm the output for Spotify?

---

<div class="post-metadata">

**Author:** ![bttstuff](https://community.folivora.ai/user_avatar/community.folivora.ai/bttstuff/32/7836_2.png) [@bttstuff](https://community.folivora.ai/u/bttstuff)\
**Post date:** [December 1, 2019, 8:48pm UTC](https://community.folivora.ai/t/kashi-show-current-song-lyrics-on-touch-bar-spotify-itunes-youtube/6301/20 "2019-12-01T20:48:24Z")

</div>

I'm a bit confused -- in the readme, it says to import the json file into btt... what does that mean specifically? i couldn't find any import button for json files, just licenses and presets.

Also, in the "Script:" part of the shell script/task trigger, do we paste the contents of the json file? Or of the .py file?

---

<div class="post-metadata">

**Author:** ![nemobushido](https://community.folivora.ai/letter_avatar_proxy/v4/letter/n/77aa72/32.png) [@nemobushido](https://community.folivora.ai/u/nemobushido)\
**Post date:** [December 3, 2019, 3:25am UTC](https://community.folivora.ai/t/kashi-show-current-song-lyrics-on-touch-bar-spotify-itunes-youtube/6301/21 "2019-12-03T03:25:31Z")

</div>

@bttstuff

Sorry if the language was confusing.

BetterTouchTool allows you to import widgets by pasting in the parameters/properties in JSON format.

So by "import", it means to just copy and paste the contents of the Kashi JSON (Select All, Copy). If it doesn't show up when you paste, make sure you have focus on the trigger column pane by clicking it first.

[Next page](https://community.folivora.ai/t/kashi-show-current-song-lyrics-on-touch-bar-spotify-itunes-youtube/6301.md?page=2)
