From f36f2fe539c21b05e06ea83aadc732ee44d785f6 Mon Sep 17 00:00:00 2001 From: cronidea <86153674+cronidea@users.noreply.github.com> Date: Wed, 18 Aug 2021 13:35:04 +0100 Subject: [PATCH] Change sb-price to allow custom currency (#963) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit e.g: price price btc Bitcoin "" gbp --- .local/bin/statusbar/sb-price | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.local/bin/statusbar/sb-price b/.local/bin/statusbar/sb-price index 35b072f..a3fb457 100755 --- a/.local/bin/statusbar/sb-price +++ b/.local/bin/statusbar/sb-price @@ -1,19 +1,22 @@ #!/bin/sh # Usage: -# price +# price # price bat "Basic Attention Token" 🦁 # When the name of the currency is multi-word, put it in quotes. [ -z "$3" ] && exit 1 + +# use $4 as currency, if not passed in use "usd" as default +currency="${4:-usd}" interval="@14d" # History contained in chart preceded by '@' (7d = 7 days) dir="${XDG_DATA_HOME:-$HOME/.local/share}/crypto-prices" pricefile="$dir/$1" chartfile="$dir/$1-chart" updateprice() { ping -q -c 1 example.org >/dev/null 2>&1 && - curl -s "rate.sx/1$1" > "$pricefile" && - curl -s "rate.sx/$1$interval" > "$chartfile" ;} + curl -s "$currency.rate.sx/1$1" > "$pricefile" && + curl -s "$currency.rate.sx/$1$interval" > "$chartfile" ;} [ -d "$dir" ] || mkdir -p "$dir" @@ -35,4 +38,4 @@ case $BLOCK_BUTTON in 6) "$TERMINAL" -e "$EDITOR" "$0" ;; esac -printf "$3$%0.2f" "$(cat "$pricefile")" +printf "$3%0.2f$currency" "$(cat "$pricefile")"