Compare commits
No commits in common. "6eed7a6523797334829626c164fa6090cbb3a3b2" and "6f63ce00ecf066b4185c5b4057cd5c213933a850" have entirely different histories.
6eed7a6523
...
6f63ce00ec
25
bin/weather
25
bin/weather
|
@ -14,34 +14,23 @@ _check_date() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
weather_loop() {
|
main() {
|
||||||
if [ $# -gt 0 ]
|
if [ "$1" == "startup" ]; then
|
||||||
then
|
_check_date
|
||||||
for ((i=1; i<=$#; i++)); do
|
if [ $? -ne 0 ]; then
|
||||||
curl --retry 10 --connect-timeout 20 wttr.in/${!i} 2>/dev/null
|
curl --retry 10 --connect-timeout 20 wttr.in 2>/dev/null
|
||||||
done
|
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
date +%d/%m/%Y > ~/.config/dotfiles/.data/weather_date
|
date +%d/%m/%Y > ~/.config/dotfiles/.data/weather_date
|
||||||
else
|
else
|
||||||
echo -e "\033[31;1mNetwork unavailable, please check your connexion or try again later.\033[0m"
|
echo -e "\033[31;1mNetwork unavailable, please check your connexion or try again later.\033[0m"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
curl --retry 10 --connect-timeout 20 wttr.in 2>/dev/null
|
curl --retry 10 --connect-timeout 20 wttr.in 2>/dev/null
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo -e "\033[31;1mNetwork unavailable, please check your connexion or try again later.\033[0m"
|
echo -e "\033[31;1mNetwork unavailable, please check your connexion or try again later.\033[0m"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
|
||||||
if [ "$1" == "startup" ]; then
|
|
||||||
_check_date
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
weather_loop ${@:2}
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
weather_loop $@
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
main $@
|
main $@
|
||||||
|
|
Loading…
Reference in New Issue