Add bitcoin-charts script and bindings

This commit is contained in:
Wiktor Zykubek 2021-02-15 12:52:02 +01:00
parent 9dc4c167fc
commit 078abb043c
2 changed files with 29 additions and 2 deletions

View File

@ -9,8 +9,8 @@ super + shift + s
super + c
compos
super + s; {t,m,n,v,c,p}
{tuirent,mails,rss,fm,ncmp,pods}
super + s; {t,m,n,v,c,p,w,b}
{tuirent,mails,rss,fm,ncmp,pods,weather-storm,bitcoin-charts}
super + a; {g,k,l,i,m}
{gimp,keepassxc,libreoffice,inkscape,minecraft-launcher}

View File

@ -0,0 +1,27 @@
#!/bin/sh
# Get Bitcoin price charts and display as image in sxiv.
DAYS="$(printf "last year\ntwo months\nlast month\nlast week\ntoday" | rofi -dmenu -p " Bitcoin Charts" -width 250)"
[ ! "$DAYS" ] && exit 1
case "$DAYS" in
"last year") DAYS="365" ;;
"two months") DAYS="60" ;;
"last month") DAYS="30" ;;
"last week") DAYS="7" ;;
"today") DAYS="1" ;;
esac
width="940"
height="700"
source_="bitstampUSD"
URL="https://bitcoincharts.com/charts/chart.png?width=${width}&height=${height}&m=${source_}&r=${DAYS}&t=S&m1=10&m2=25"
CURRENT_PRICE="$(curl -s rate.sx/1btc | sed 's/\(.*\).\{5\}$/\1/')"
curl -k -s "$URL" -o /tmp/bitcoinchart
convert -pointsize 14 -font helvetica-bold -fill black -gravity North -draw "text 0,12 \"\$${CURRENT_PRICE}\"" \
-fill white -draw "rectangle 900,0 702,30" /tmp/bitcoinchart /tmp/bitcoinchart
sxiv -b /tmp/bitcoinchart
rm /tmp/bitcoinchart