diff options
author | terminaldweller <thabogre@gmail.com> | 2023-02-18 17:37:42 +0000 |
---|---|---|
committer | terminaldweller <thabogre@gmail.com> | 2023-02-18 17:37:42 +0000 |
commit | cb545061e4c4207667ca898c2dc21c35477987ee (patch) | |
tree | f163b8c64e4aa4e44d0b3397f3f7120b9b2eb7d5 /tmux/vcs_info.sh | |
parent | update (diff) | |
download | scripts-cb545061e4c4207667ca898c2dc21c35477987ee.tar.gz scripts-cb545061e4c4207667ca898c2dc21c35477987ee.zip |
update
Diffstat (limited to '')
-rwxr-xr-x | tmux/vcs_info.sh | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/tmux/vcs_info.sh b/tmux/vcs_info.sh index ba8b6a8..673c07e 100755 --- a/tmux/vcs_info.sh +++ b/tmux/vcs_info.sh @@ -66,10 +66,38 @@ function repo_info { } function get_eth_price { - eth_price=$(proxychains4 -q -f ~/proxies/ice/proxychains.conf curl -s -X GET "https://api.terminaldweller.com/crypto/v1/price?name=ETH&unit=USD" | jq ".price") - cake_price=$(proxychains4 -q -f ~/proxies/ice/proxychains.conf curl -s -X GET "https://api.terminaldweller.com/crypto/v1/price?name=CAKE&unit=USD" | jq ".price") - monero_price=$(proxychains4 -q -f ~/proxies/ice/proxychains.conf curl -s -X GET "https://api.terminaldweller.com/crypto/v1/price?name=XMR&unit=USD" | jq ".price") - echo "${eth_price}/${cake_price}/${monero_price}" + PRICE_TIME_CACHE=60 + PRICE_CACHE_OUTPUT_ETH=/tmp/tmux_PRICE_CACHE_ETH + PRICE_CACHE_OUTPUT_XMR=/tmp/tmux_PRICE_CACHE_XMR + PRICE_CACHE_OUTPUT_CAKE=/tmp/tmux_PRICE_CACHE_CAKE + # eth_price=$(proxychains4 -q -f ~/proxies/ice/proxychains.conf curl -s -X GET "https://api.terminaldweller.com/crypto/v1/price?name=ETH&unit=USD" | jq ".price") + # cake_price=$(proxychains4 -q -f ~/proxies/ice/proxychains.conf curl -s -X GET "https://api.terminaldweller.com/crypto/v1/price?name=CAKE&unit=USD" | jq ".price") + # monero_price=$(proxychains4 -q -f ~/proxies/ice/proxychains.conf curl -s -X GET "https://api.terminaldweller.com/crypto/v1/price?name=XMR&unit=USD" | jq ".price") + if [ $(( $( stat --format=%Y $PRICE_CACHE_OUTPUT_ETH ) + PRICE_TIME_CACHE )) -gt "$( date +%s )" ];then + : + else + if ETH_OUTPUT=$(proxychains4 -q -f ~/proxies/ice/proxychains.conf curl -s -X GET "https://api.terminaldweller.com/crypto/v1/price?name=ETH&unit=USD" | jq ".price"); then + echo "${ETH_OUTPUT}" > ${PRICE_CACHE_OUTPUT_ETH} + fi + fi + if [ $(( $( stat --format=%Y $PRICE_CACHE_OUTPUT_CAKE ) + PRICE_TIME_CACHE )) -gt "$( date +%s )" ];then + : + else + if CAKE_OUTPUT=$(proxychains4 -q -f ~/proxies/ice/proxychains.conf curl -s -X GET "https://api.terminaldweller.com/crypto/v1/price?name=CAKE&unit=USD" | jq ".price"); then + echo "${CAKE_OUTPUT}" > ${PRICE_CACHE_OUTPUT_CAKE} + fi + fi + if [ $(( $( stat --format=%Y $PRICE_CACHE_OUTPUT_XMR ) + PRICE_TIME_CACHE )) -gt "$( date +%s )" ];then + : + else + if XMR_OUTPUT=$(proxychains4 -q -f ~/proxies/ice/proxychains.conf curl -s -X GET "https://api.terminaldweller.com/crypto/v1/price?name=XMR&unit=USD" | jq ".price"); then + echo "${XMR_OUTPUT}" > ${PRICE_CACHE_OUTPUT_XMR} + fi + fi + + + result="$(cat ${PRICE_CACHE_OUTPUT_ETH})"/"$(cat ${PRICE_CACHE_OUTPUT_CAKE})"/"$(cat ${PRICE_CACHE_OUTPUT_XMR})" + echo "${result}" } tmux_session_info=" #S:#I.#P" |