From 7659b826b5c333440864d0eaef9656cdf4ad7b58 Mon Sep 17 00:00:00 2001 From: Riyyi Date: Fri, 6 Aug 2021 22:01:43 +0200 Subject: [PATCH] Polybar: Add rate limit message to BTC module --- .local/bin/panel/btc.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.local/bin/panel/btc.sh b/.local/bin/panel/btc.sh index 05b2be4..76d6b7b 100755 --- a/.local/bin/panel/btc.sh +++ b/.local/bin/panel/btc.sh @@ -39,6 +39,8 @@ url_last_week="${url}/history?interval=h1&start=${date_last_week_start}&end=${da # Current price data="$(data "$url")" +data_first_character="$(echo "$data" | cut -c 1)" +if [ "$data_first_character" != "{" ]; then echo "rate limit"; exit; fi price="$(echo "$data" | jq --compact-output --raw-output '.data.priceUsd')" price=$(calc "$price") @@ -47,7 +49,10 @@ difference_yesterday="$(echo "$data" | jq --compact-output --raw-output '.data.c difference_yesterday="$(calc "$difference_yesterday")" # Get last weeks difference -price_last_week="$(data "$url_last_week" | jq --compact-output --raw-output '.data[0].priceUsd')" +data_last_week="$(data "$url_last_week")" +data_last_week_first_character="$(echo "$data_last_week" | cut -c 1)" +if [ "$data_last_week_first_character" != "{" ]; then echo "rate limit"; exit; fi +price_last_week="$(echo "$data_last_week" | jq --compact-output --raw-output '.data[0].priceUsd')" difference_last_week=$(calc "$price / $price_last_week * 100 - 100") # Create output formatting