system/programs/xmonad/xmobar/scripts/cbr.sh

28 lines
577 B
Bash
Executable file

#!/bin/bash
set -e
today=$(date +%d/%m/%Y)
prev_week=$(date +%d/%m/%Y -d '-7 day')
usd=R01235
cc=($(curl --no-progress-meter "https://www.cbr.ru/scripts/XML_dynamic.asp?date_req1=$prev_week&date_req2=$today&VAL_NM_RQ=$usd" | \
sed -e "s/<[A-Z]/\n\0/g" | \
grep Value | \
sed -e "s#<\/\?\w\+>##g" | \
sed -e "s/,/./g"))
diff=$(echo ${cc[-1]} ${cc[-2]} | awk '{ print $1 - $2 }')
arror="↑"
color='#50fa7b'
if [ ${diff:0:1} == '-' ]; then
diff=${diff:1}
arror="↓"
color='#ff5555'
fi
echo "${cc[-1]} (<fc=${color}>${arror}<hspace=3/>${diff}</fc>)"
exit 0