mirror of
https://github.com/avinal/dotfiles.git
synced 2026-07-03 23:20:07 +05:30
c2786c7f96
- move older config to archive Signed-off-by: Avinal Kumar <avinal.xlvii@gmail.com>
19 lines
509 B
Bash
Executable File
19 lines
509 B
Bash
Executable File
#!/usr/bin/env bash
|
|
# get_weather.sh
|
|
for i in {1..5}
|
|
do
|
|
text=$(curl -s "https://wttr.in/$1?format=1")
|
|
if [[ $? == 0 ]]
|
|
then
|
|
text=$(echo "$text" | sed -E "s/\s+/ /g")
|
|
tooltip=$(curl -s "https://wttr.in/$1?format=4")
|
|
if [[ $? == 0 ]]
|
|
then
|
|
tooltip=$(echo "$tooltip" | sed -E "s/\s+/ /g")
|
|
echo "{\"text\":\"$text\", \"tooltip\":\"$tooltip\"}"
|
|
exit
|
|
fi
|
|
fi
|
|
sleep 2
|
|
done
|
|
echo "{\"text\":\"error\", \"tooltip\":\"error\"}" |