-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcrypto
More file actions
executable file
·43 lines (34 loc) · 1.09 KB
/
crypto
File metadata and controls
executable file
·43 lines (34 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/sh
crypto=doge
. "${XDG_CACHE_HOME-$HOME/.cache}/wal/colors.sh"
blockcolor=$color1
txtcolor=$color0
case $BLOCK_BUTTON in
1) setsid "$TERMINAL" -e less -Srf
;;
2)
;;
6) "$TERMINAL" -e "$EDITOR" "$0"
;;
esac
# Usage:
# price <url> <Name of currency> <icon>
# price bat "Basic Attention Token" 🦁
# When the name of the currency is multi-word, put it in quotes.
# interval="@14d" # History contained in chart preceded by '@' (7d = 7 days)
ping -q -c 1 rate.sx >/dev/null || exit 1
crypto_info=$(curl -s "https://rate.sx/$crypto")
price=$(echo "$crypto_info" | grep end | cut -d' ' -f8)
delta=$(echo "$crypto_info" | head -2 | xargs | tr ' ' '\n' | tail -1)
case $crypto in
btc) icon='B';;
eth) icon='';;
doge) icon='🐕';;
xmr) icon='M';;
esac
printf "<b><span foreground='%s' background='%s'></span>" \
"$blockcolor" "$color0"
printf "<span foreground='%s' background='%s'> %s </span>" \
"$txtcolor" "$blockcolor" "$icon $(echo $crypto | tr '[:lower:]' '[:upper:]') $price ($delta)"
printf "<span foreground='%s' background='%s'></span></b>\n" \
"$color0" "$blockcolor"