Before anything is even remotely possible you’ll need to install the following applications:

Many people want to track the price of Gulden all day long. Thanks to the MacBook Pro Touch Bar it’s possible in a whole new way!

JSON Helper for AppleScript to help AppleScript better process JSON.

BetterTouchTool, a piece of software for putting your Touch Bar to good use, next to many other features.

After you’ve installed BetterTouchTool: run it, go to the TouchBar tab and click the + Widget button. Next, in the Select Widget drop down, select Run Apple Script and Show Value and then click Advanced configuration.

After that you can name your widget, mine is called Gulden. Then you can use the following script to get the data from Nocks Trade to fill it with the correct data. Just copy and paste it into the text field and you’ll be good to go!

set mJson to do shell script "curl -s 'https://guldendex.com/api/eurprice.php'"

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 15 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 theKeyValuePair to item 12 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 change to item 2 of theKeyValueBufferList

set usdPrice to RemoveFromString("\"", usdPrice)

set usdPrice to RoundImperialNumberToTwoDecimals(usdPrice)

set change to RemoveFromString("\"", change)

set arrow to " ▲"

if change < 0 then

set arrow to " ▼"

end if

set unformatedValue to "€ " & usdPrice & " " & arrow & " " & change & "%"

return RemoveFromString("\"", unformatedValue)

-- remove character or string from given string

on RemoveFromString(CharOrString, txt)

set AppleScript's text item delimiters to CharOrString

set temp to txt's text items

set AppleScript's text item delimiters to ""

return temp as text

end RemoveFromString

on RoundImperialNumberToTwoDecimals(txt)

set AppleScript's text item delimiters to "."

set decimals to text item 2 of txt

if (count decimals) < 2 then

set decimals to decimals & "0"

end if

set decimals to (text 1 thru 4 of decimals)

set theNumber to text item 1 of txt & "." & decimals

set AppleScript's text item delimiters to ""

return theNumber

end RoundImperialNumberToTwoDecimals

This code will retrieve the last price at Nocks Trade and return it to the widget. I won’t take any credit for this piece of script, I found it at this post and as you can read the original came from Charlie Lee. I just altered it to show the price in Euro and traded the source of the data to my own source that gets the data from the Nocks API. I also altered it to show 4 decimals like Nocks does.

Now you can style your widget. First up, the logo. I used the following one: https://dev.gulden.com/images/branding/gwhite32x32.png. You can just drag it into BetterTouchTool in the icon slot and after that the alternative icon slot. For the Touchbar Button Collor and the Alternate Color i used #2AB0FD since it’s the original Gulden color as stated on their website https://dev.gulden.com/contribute/.

If you styled your widget to your likings please set the Execute this script every x seconds to above 60 seconds to make sure my server won’t overheat! Click save and you’re done!

Let me know if you like it!

Want to know more about Gulden? Check out their website at https://gulden.com/

The original post about this ticker can be found here. It’s written by Noom.