From 078abb043cc50eedff3901a9ea5b5be31759176d Mon Sep 17 00:00:00 2001 From: Wiktor Zykubek Date: Mon, 15 Feb 2021 12:52:02 +0100 Subject: [PATCH] Add bitcoin-charts script and bindings --- .config/sxhkd/sxhkdrc | 4 ++-- .local/bin/scripts/bitcoin-charts | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) create mode 100755 .local/bin/scripts/bitcoin-charts diff --git a/.config/sxhkd/sxhkdrc b/.config/sxhkd/sxhkdrc index 702b71b..8e91894 100644 --- a/.config/sxhkd/sxhkdrc +++ b/.config/sxhkd/sxhkdrc @@ -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} diff --git a/.local/bin/scripts/bitcoin-charts b/.local/bin/scripts/bitcoin-charts new file mode 100755 index 0000000..7a439eb --- /dev/null +++ b/.local/bin/scripts/bitcoin-charts @@ -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