Skip to content

Instantly share code, notes, and snippets.

@Pe8er
Created April 20, 2018 04:04
Show Gist options
  • Save Pe8er/a37729b8fd55a7fd5f9674103659827a to your computer and use it in GitHub Desktop.
Save Pe8er/a37729b8fd55a7fd5f9674103659827a to your computer and use it in GitHub Desktop.
set APIKey to "????" -- your secret Dark Sky API key. Get it here: https://darksky.net/dev/account
tell application "JSON Helper"
try
set latLon to do shell script "/usr/local/bin/locateme -f '{LAT},{LON}'"
set weather to fetch JSON from "https://api.darksky.net/forecast/" & APIKey & "/" & latLon & "?exclude=minutely,hourly,daily,alerts,flags&units=si"
on error e
return e
end try
try
set temperature to temperature of currently of weather
set weatherStatus to icon of currently of weather
set summary to summary of currently of weather
on error
return "¯\\_(ツ)_/¯"
end try
end tell
if weatherStatus is equal to "clear-day" then
set myIcon to "☀️"
else if weatherStatus is equal to "clear-night" then
set myIcon to "🌙"
else if weatherStatus is equal to "partly-cloudy-day" then
set myIcon to "🌤"
else if weatherStatus is equal to "partly-cloudy-night" then
set myIcon to "☁️🌙"
else if weatherStatus is equal to "cloudy" then
set myIcon to "☁️"
else if weatherStatus is equal to "rain" then
set myIcon to "🌧"
else if weatherStatus is equal to "sleet" then
set myIcon to "⛈"
else if weatherStatus is equal to "fog" then
set myIcon to "🌫️"
else if weatherStatus is equal to "wind" then
set myIcon to "🌀"
else if weatherStatus is equal to "snow" then
set myIcon to "❄️"
else
set myIcon to weatherStatus
end if
return myIcon & " " & (round (temperature)) & "°" -- & space & summary
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment