aboutsummaryrefslogtreecommitdiffstats
path: root/tmux
diff options
context:
space:
mode:
authorterminaldweller <thabogre@gmail.com>2023-02-18 17:37:42 +0000
committerterminaldweller <thabogre@gmail.com>2023-02-18 17:37:42 +0000
commitcb545061e4c4207667ca898c2dc21c35477987ee (patch)
treef163b8c64e4aa4e44d0b3397f3f7120b9b2eb7d5 /tmux
parentupdate (diff)
downloadscripts-cb545061e4c4207667ca898c2dc21c35477987ee.tar.gz
scripts-cb545061e4c4207667ca898c2dc21c35477987ee.zip
update
Diffstat (limited to 'tmux')
-rwxr-xr-xtmux/date.sh14
-rwxr-xr-xtmux/vcs_info.sh36
2 files changed, 41 insertions, 9 deletions
diff --git a/tmux/date.sh b/tmux/date.sh
index 7a82d91..ce6e0eb 100755
--- a/tmux/date.sh
+++ b/tmux/date.sh
@@ -3,16 +3,18 @@
# source common.sh
SEPARATOR_LEFT_BOLD=""
SEPARATOR_LEFT_THIN=""
-PROXY="proxychains4 -q -f /home/devi/proxies/ice/proxychains.conf"
+# PROXY="proxychains4 -q -f /home/devi/proxies/ice/proxychains.conf"
internet_time_cache() {
INTERNET_TIME_CACHE_AGE=60
INTERNET_TIME_CACHE_OUTPUT=/tmp/tmux_internet_time_cache
# if the cache has not expired yet
- if [ $(( $( stat --format=%Y $INTERNET_TIME_CACHE_OUTPUT ) + INTERNET_TIME_CACHE_AGE )) -gt $( date +%s ) ];then
+ if [ $(( $( stat --format=%Y $INTERNET_TIME_CACHE_OUTPUT ) + INTERNET_TIME_CACHE_AGE )) -gt "$( date +%s )" ];then
:
else
- date -u +"%T" -d @$(curl -s --connect-timeout 10 --socks5-hostname localhost:9054 --user-agent "$(get_random_ua.sh)" http://worldtimeapi.org/api/timezone/Europe/London.json | jq '.unixtime') > ${INTERNET_TIME_CACHE_OUTPUT}
+ if OUTPUT=$(date -u +"%T" -d @$(curl -s --connect-timeout 10 --socks5-hostname localhost:9053 --user-agent "$(get_random_ua.sh)" http://worldtimeapi.org/api/timezone/Europe/London.json | jq '.unixtime')); then
+ echo "${OUTPUT}" > ${INTERNET_TIME_CACHE_OUTPUT}
+ fi
fi
cat ${INTERNET_TIME_CACHE_OUTPUT}
}
@@ -20,10 +22,12 @@ internet_time_cache() {
weather_info_cache() {
WEATHER_INFO_CACHE_AGE=300
WEATHER_INFO_CACHE_OUTPUT=/tmp/tmux_weather_info_cache
- if [ $(( $( stat --format=%Y $WEATHER_INFO_CACHE_OUTPUT ) + INTERNET_TIME_CACHE_AGE )) -gt $( date +%s ) ];then
+ if [ $(( $( stat --format=%Y $WEATHER_INFO_CACHE_OUTPUT ) + WEATHER_INFO_CACHE_AGE )) -gt "$( date +%s )" ];then
:
else
- ${PROXY} curl -s 'wttr.in/tehran?T&format=%f' > ${WEATHER_INFO_CACHE_OUTPUT}
+ if OUTPUT=$(curl -s --connect-timeout 10 --socks5-hostname socks5h://127.0.0.1:9053 'wttr.in/tehran?T&format=%f'); then
+ echo "${OUTPUT}" > ${WEATHER_INFO_CACHE_OUTPUT}
+ fi
fi
cat ${WEATHER_INFO_CACHE_OUTPUT}
}
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"