Crypto ticker for MacBook Touch Bar
set symbol to "BTC"
on trimString(theString)
repeat until theString does not start with " "
set theString to text 2 thru -1 of theString
end repeat
repeat until theString does not end with " "
set theString to text 1 thru -2 of theString
end repeat
return theString
end trimString
on splitString(theString, theDelimiter)
set oldDelimiters to AppleScript's text item delimiters
set AppleScript's text item delimiters to theDelimiter
set theArray to every text item of theString
set AppleScript's text item delimiters to oldDelimiters
return theArray
end splitString
on truncatePrice(price)
set pieces to my splitString(price, ".")
set decimals to second item of pieces
set truncated to text 1 thru 3 of decimals
return first item of pieces & "." & truncated
end truncatePrice
set command to "/usr/local/bin/node /usr/local/bin/coinmon --find " & symbol & " --convert EUR | grep " & symbol
set output to do shell script command
set columns to my splitString(output, "│")
set price to third item of columns
set trimmedPrice to my trimString(price)
set truncatedPrice to my truncatePrice(trimmedPrice)
set delta to my trimString(fifth item of columns)
set sign to first item of delta
return delta
if sign is "-" then
set changeSign to "📉"
else
set changeSign to "🚀"
end if
return changeSign & " " & symbol & " " & truncatedPrice
npm
on command line)npm install -g coinmon