feat(prog/xmonad/xmobar): add exchangerate.host api
... and use it by default
This commit is contained in:
parent
51eb6d10d7
commit
141ac97ce5
3 changed files with 42 additions and 29 deletions
|
@ -1,28 +0,0 @@
|
||||||
#!/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
|
|
||||||
|
|
41
programs/xmonad/xmobar/scripts/exchangerate.sh
Executable file
41
programs/xmonad/xmobar/scripts/exchangerate.sh
Executable file
|
@ -0,0 +1,41 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
curl_cbr () {
|
||||||
|
local today=$(date +%d/%m/%Y)
|
||||||
|
local prev_week=$(date +%d/%m/%Y -d '-7 day')
|
||||||
|
local usd=R01235
|
||||||
|
|
||||||
|
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"
|
||||||
|
}
|
||||||
|
|
||||||
|
curl_exchangerate () {
|
||||||
|
local start_date=$(date +%Y-%m-%d -d '-1 day')
|
||||||
|
local end_date=$(date +%Y-%m-%d)
|
||||||
|
|
||||||
|
curl --no-progress-meter -X GET "https://api.exchangerate.host/timeseries?start_date=$start_date&end_date=$end_date&base=USD&symbols=RUB&places=4&format=xml" | \
|
||||||
|
sed -e "s/<[a-z]/\n\0/g" | \
|
||||||
|
grep rate | \
|
||||||
|
sed -e "s#<\/\?\w\+>##g"
|
||||||
|
}
|
||||||
|
|
||||||
|
cc=($(curl_exchangerate))
|
||||||
|
|
||||||
|
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
|
||||||
|
|
|
@ -84,7 +84,7 @@ myCommands =
|
||||||
]
|
]
|
||||||
(10 `seconds`)
|
(10 `seconds`)
|
||||||
, Run $ ComX "/bin/bash" ["-c", "~/.config/xmobar/scripts/get_volume.sh"] "N/A" "volume" 1
|
, Run $ ComX "/bin/bash" ["-c", "~/.config/xmobar/scripts/get_volume.sh"] "N/A" "volume" 1
|
||||||
, Run $ ComX "/bin/bash" ["-c", "~/.config/xmobar/scripts/cbr.sh"] "N/A" "usdrub" (60 `seconds`)
|
, Run $ ComX "/bin/bash" ["-c", "~/.config/xmobar/scripts/exchangerate.sh"] "N/A" "usdrub" (60 `seconds`)
|
||||||
, Run XMonadLog
|
, Run XMonadLog
|
||||||
]
|
]
|
||||||
where
|
where
|
||||||
|
|
Loading…
Reference in a new issue