Skip to content

Instantly share code, notes, and snippets.

@tomkap
Created September 21, 2015 19:14
Show Gist options
  • Save tomkap/9d3b5a411f9ab93e32ea to your computer and use it in GitHub Desktop.
Save tomkap/9d3b5a411f9ab93e32ea to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# .conkyrc:
# ${execi 28800 ~/i3/weather.sh}
METRIC="metric" && UNIT="C"
GEOLOC=$(curl -s ipinfo.io)
LATLON=$(echo $GEOLOC | jq -r '.loc')
LAT=${LATLON%,*}
LON=${LATLON#*,}
WEATHER=$(curl -s http://api.openweathermap.org/data/2.5/weather\?lat\=${LAT}\&lon\=${LON}\&units\=${METRIC})
CITY=$(echo $WEATHER | jq -r '.name')
TEMPER=$(printf '%.0f' $(echo $WEATHER | jq '.main.temp'))
CONDIT=$(echo $WEATHER | jq -r '.weather[0].main')
echo "$TEMPER $UNIT ($CONDIT) in $CITY"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment