The following program is a simple guide that uses BetterTouchTool to display crypto currency prices on your macbook touchbar. The end result will look something like the image below.
You will need a macbook with touchbar and you will also need BetterTouchTool installed which you can find over here https://folivora.ai/
-
Install better touch tool
-
Install json-helper to make scripting easier, https://itunes.apple.com/dk/app/json-helper-for-applescript/id453114608?mt=12
-
Click the touchbar tab on BTT
-
Click on the +Widget button
-
In the Select Widget drop down select Run Apple Script and Show Value, and click on Advanced configuration
-
Name the widget , for our first one we can call it "BTC"
-
Copy paste the following code
set mJson to do shell script "curl -s 'https://api.coinmarketcap.com/v1/ticker/bitcoin/'"
set AppleScript's text item delimiters to {","}
set keyValueList to (every text item in mJson) as list
set AppleScript's text item delimiters to ""
set theKeyValuePair to item 5 of keyValueList
set AppleScript's text item delimiters to {": "}
set theKeyValueBufferList to (every text item in theKeyValuePair) as list
set AppleScript's text item delimiters to ""
set usdPrice to item 2 of theKeyValueBufferList
set usdPrice to text 2 thru -2 of usdPrice
set usdPrice to round (usdPrice)
return "$" & usdPrice
The above script simply calls the coinmarketcap api url endpoint for bitcoin and then parses the usdPrice value and rounds this value. You can look at the files inside the AppleScript folder for more examples.
-
Save
-
Now you can work on adding a cool logo. I found my logo's by going to coinmarketcap and downloading each coins logo
-
You can now simply add the logo by clicking on the logo option in BTT and dragging the corresponding image file.
-
Now if you want to define an action when you click on the touchbar for this coin, you can simply define an action. I wanted mine to load up coinmarketcap bitcoin page, so i choose "run apple script (async in background)" in the "predfined action" section.
-
Now I copy paste the following code to tell chrome to open the corresponding website.
tell application "Google Chrome"
if it is running then
open location "https://coinmarketcap.com/"
else
activate
open location "https://coinmarketcap.com/"
delay 1
activate
end if
end tell
-
Next I repeated steps 4-12 for all the other coins I wanted to track by simply chaning the url on the applescript to the corresponding coin I wanted to track.
-
You are ready to go, you should have a crypto ticker active on your touchbar