Created
April 20, 2018 04:04
-
-
Save Pe8er/a37729b8fd55a7fd5f9674103659827a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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