autocreate dir and show price before getting chart
This commit is contained in:
parent
bad0b625a6
commit
06fb70a6cb
1 changed files with 4 additions and 4 deletions
|
@ -7,15 +7,17 @@
|
||||||
|
|
||||||
[ -z "$3" ] && exit 1
|
[ -z "$3" ] && exit 1
|
||||||
interval="@7d" # History contained in chart preceded by '@' (7d = 7 days)
|
interval="@7d" # History contained in chart preceded by '@' (7d = 7 days)
|
||||||
|
|
||||||
# Directory where currency info is stored.
|
|
||||||
dir="${XDG_DATA_HOME:-$HOME/.local/share}/crypto-prices"
|
dir="${XDG_DATA_HOME:-$HOME/.local/share}/crypto-prices"
|
||||||
pricefile="$dir/$1"
|
pricefile="$dir/$1"
|
||||||
chartfile="$dir/$1-chart"
|
chartfile="$dir/$1-chart"
|
||||||
|
|
||||||
|
[ -d "$dir" ] || mkdir -p "$dir"
|
||||||
|
|
||||||
[ "$(stat -c %x "$pricefile" 2>/dev/null | cut -d' ' -f1)" != "$(date '+%Y-%m-%d')" ] &&
|
[ "$(stat -c %x "$pricefile" 2>/dev/null | cut -d' ' -f1)" != "$(date '+%Y-%m-%d')" ] &&
|
||||||
{ ping -q -c 1 1.1.1.1 >/dev/null 2>&1 && curl -s "rate.sx/1$1" > "$pricefile" || exit ;}
|
{ ping -q -c 1 1.1.1.1 >/dev/null 2>&1 && curl -s "rate.sx/1$1" > "$pricefile" || exit ;}
|
||||||
|
|
||||||
|
printf "$3$%0.2f" "$(cat "$pricefile")"
|
||||||
|
|
||||||
[ "$(stat -c %x "$chartfile" 2>/dev/null | cut -d' ' -f1)" != "$(date '+%Y-%m-%d')" ] &&
|
[ "$(stat -c %x "$chartfile" 2>/dev/null | cut -d' ' -f1)" != "$(date '+%Y-%m-%d')" ] &&
|
||||||
{ ping -q -c 1 1.1.1.1 >/dev/null 2>&1 && curl -s "rate.sx/$1$interval" > "$chartfile" || exit ;}
|
{ ping -q -c 1 1.1.1.1 >/dev/null 2>&1 && curl -s "rate.sx/$1$interval" > "$chartfile" || exit ;}
|
||||||
|
|
||||||
|
@ -30,5 +32,3 @@ case $BLOCK_BUTTON in
|
||||||
$uptime</b>" ;;
|
$uptime</b>" ;;
|
||||||
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
printf "$3$%0.2f" "$(cat "$pricefile")"
|
|
||||||
|
|
Loading…
Reference in a new issue