dotfiles/.local/bin/custom/rateUSD
ziro 8622acb8d9 ----- Changes: lfrc, polybar, rateUSD
+ Rework lfrc
+ Integrated rateUSD to Polybar
+ Added lang option
2020-05-19 09:02:16 +07:00

8 lines
598 B
Bash
Executable file

#!/bin/sh
# get rate value from cnbcindonesia.com
[ ! "$(stat -c %y ~/.cache/rateUSD.txt 2> /dev/null | cut -d' ' -f1)" = "$(date "+Y-%m-%d")" ] && curl -s "https://www.cnbcindonesia.com/market-data/currencies/IDR=/USD-IDR" | grep -A1 'class="mark_val"' | cut -d'"' -f2 | cut -d'<' -f2 | cut -d'>' -f2 > ~/.cache/rateUSD.txt
enUS='Rate'
idID='Kurs'
lang=$idID
# display rateUSD.txt while replace mark_val with Kurs USD -> IDR:
[ -z $1 ] && sed "s/mark_val/$lang USD -> IDR:/;2 s/^/Rp./" ~/.cache/rateUSD.txt && echo "Sumber: CNBC Indonesia" || grep -A1 "mark" ~/.cache/rateUSD.txt | grep -v "mark"