25 lines
584 B
Bash
Executable File
25 lines
584 B
Bash
Executable File
#!/bin/bash
|
|
|
|
# blob:summary=Returns a formatted weather status string with temperature and wind speed.
|
|
|
|
place=$(blob-weather-location 2>/dev/null)
|
|
|
|
if [[ -z $place ]]; then
|
|
echo "Weather unavailable"
|
|
exit 1
|
|
fi
|
|
|
|
query=$(jq -rn --arg place "$place" '$place | @uri')
|
|
weather=$(curl -fsS --max-time 4 "https://wttr.in/${query}?format=%t|%w" 2>/dev/null | tr -d '\n')
|
|
|
|
if [[ -z $weather ]]; then
|
|
echo "Weather unavailable"
|
|
exit 1
|
|
fi
|
|
|
|
IFS='|' read -r temperature wind <<< "$weather"
|
|
place=${place^}
|
|
temperature=${temperature#+}
|
|
|
|
echo "$place · Temp $temperature · Wind $wind"
|