scripts

unixus scriptus
git clone https://s.sonu.ch/~roket1428/scripts.git
Log | Files | Refs

wttr (473B)


      1 #!/bin/sh
      2 
      3 # Get weather information via openweathermap api
      4 # requires curl, jq and $XDG_CACHE_HOME to be set
      5 
      6 # https://bulk.openweathermap.org/sample/city.list.json.gz
      7 # find your city id and change this
      8 cityid=""
      9 
     10 # get your api key from openweathermap.org
     11 apikey=""
     12 
     13 curl -so "$XDG_CACHE_HOME"/wttr "http://api.openweathermap.org/data/2.5/weather?id=${cityid}&appid=${apikey}&units=metric"
     14 
     15 temp=$(jq ".main.temp" "$XDG_CACHE_HOME"/wttr)
     16 
     17 printf "%0.f°C\\n" "$temp"
     18 
     19