You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
871 B
Bash
21 lines
871 B
Bash
2 years ago
|
#!/bin/bash
|
||
|
#source "$HOME/.dotfiles/.priv/key"
|
||
|
#source "$HOME/.dotfiles/bin/weather/.env.location"
|
||
|
#source "$HOME/.dotfiles/bin/weather/.env.weather"
|
||
|
# API_KEY=$(cat "$HOME/.dotfiles/bin/weather/.priv/key")
|
||
|
# getting weather
|
||
|
CUR_TIMESTAMP=$(date +%s)
|
||
|
# only update weather every 30 seconds
|
||
|
|
||
|
if [[ $CUR_TIMESTAMP -gt $EXPIRATION || -z $EXPIRATION ]] ; then
|
||
|
WEATHER=$(curl --silent "http://wttr.in/${LOCATION}?format=j2" | gojq -r '.current_condition[0]')
|
||
|
|
||
|
echo $WEATHER
|
||
|
TEMP=$(echo $WEATHER | gojq -r '.temp_F')
|
||
|
HUMIDITY=$(echo $WEATHER | gojq -r '.humidity')
|
||
|
ICON=$(echo $WEATHER | gojq -r '.weatherCode')
|
||
|
EXPIRATION=$(($CUR_TIMESTAMP+30))
|
||
|
echo "TEMP: $TEMP HUMIDITY: $HUMIDITY ICON: $ICON"
|
||
|
#printf 'TEMP=%s\nHUMIDITY=%s\nICON=%s\nEXPIRATION=%s\n' "$TEMP" "$HUMIDITY" "$ICON" "$EXPIRATION" >"$HOME/.dotfiles/bin/weather/.env.weather"
|
||
|
fi
|