----- Changes: lfrc, polybar, rateUSD

+ Rework lfrc
+ Integrated rateUSD to Polybar
+ Added lang option
This commit is contained in:
ziro 2020-05-19 09:02:16 +07:00
parent 1b9fe5b22f
commit 8622acb8d9
3 changed files with 21 additions and 6 deletions

View file

@ -1,7 +1,8 @@
#!/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
[ ! "$(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:
sed 's/mark_val/Kurs USD -> IDR:/' ~/.cache/rateUSD.txt; echo "Sumber: CNBC Indonesia"
[ -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"