From bdc4a420002a286a2cabac98d44fa3cd0470ee15 Mon Sep 17 00:00:00 2001 From: Riyyi Date: Tue, 4 Jan 2022 17:08:49 +0100 Subject: [PATCH] Scripts: Dont attempt to pull btc price if done recently --- .local/bin/panel/btc.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.local/bin/panel/btc.sh b/.local/bin/panel/btc.sh index 31f82af..00cce86 100755 --- a/.local/bin/panel/btc.sh +++ b/.local/bin/panel/btc.sh @@ -30,6 +30,10 @@ output() { echo "%{F$color}$symbol $difference%%{F$COLOR15}" } +# Only pull if older than 10 seconds +lastModified=$(calc "$(date +%s) - $(date +%s -r $file) >= 10" | cut -c 1) +if [ "$lastModified" -eq 0 ]; then cat "$file"; exit; fi + # Get dates date_last_week_start="$(date --date 'last week' +%s000)" date_last_week_end=$(calc "$date_last_week_start + (1000 * 60 * 60)") # +1h