From 4362eaa8d7ed341d241c5ef7146176a03dd00948 Mon Sep 17 00:00:00 2001 From: Dane Williams Date: Sun, 15 Mar 2020 12:41:10 -0700 Subject: [PATCH] fixed sleep command bug --- dracula.tmux | 1 + sleep_weather.sh | 13 ++++++------- weather.sh | 2 -- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/dracula.tmux b/dracula.tmux index 234b157..462c984 100755 --- a/dracula.tmux +++ b/dracula.tmux @@ -51,6 +51,7 @@ main() tmux set-window-option -g window-status-current-format "#[fg=${white},bg=${dark_purple}] #I #W " tmux set-window-option -g window-status-format "#[fg=${white}]#[bg=${gray}] #I #W " + # run weather update script in background ./sleep_weather.sh & } diff --git a/sleep_weather.sh b/sleep_weather.sh index 67350e9..dad1086 100755 --- a/sleep_weather.sh +++ b/sleep_weather.sh @@ -4,15 +4,14 @@ main() { - while tmux has-session &> /dev/null + while true do ./weather.sh > ~/.tmux/plugins/tmux-dracula/weather.txt - # error=$(cat ~/.tmux/plugins/tmux-dracula/weather.txt | sed -n 2p) - # if [ $error = ' "error": {' ]; then - # echo "Too Many Requests" > ~/.tmux/plugins/tmux-dracula/weather.txt - # break - # fi - sleep 1000 + if tmux has-session &> /dev/null; then + sleep 1000 + else + break + fi done } diff --git a/weather.sh b/weather.sh index 756c952..65f8fdd 100755 --- a/weather.sh +++ b/weather.sh @@ -12,8 +12,6 @@ country=$(curl -s https://ipinfo.io/country 2> /dev/null) region_code_url=http://www.ip2country.net/ip2country/region_code.html weather_url=https://forecast.weather.gov/zipcity.php -zip=46556 - #substitute region code for regions in north america get_region_code() {