#! /bin/bash

# 2025-01-16 20:45:26 reordered, a hint for the XFCE command output applet

if jq --version &>/dev/null; then

    price1=`curl --silent --max-time 7 https://api.coindesk.com/v1/bpi/currentprice.json 2>/dev/null | jq .bpi.USD.rate | sed 's/,//g;s/"//g'` # due to a number format: 8,255.3913

    price3=`curl --silent --max-time 7 'https://api.coingecko.com/api/v3/coins/bitcoin?developer_data=false&community_data=false&tickers=false' | jq '.market_data.current_price.usd'`

    printf "<txt> %'.f %'.f </txt>" "$price3" "$price1" 2>/dev/null
    echo "<tool>1st: coingecko.com; 2nd: coindesk.com;</tool>"
    echo "<txtclick>firefox https://coingecko.com</txtclick>"

else

    echo "Install jq"

fi