forked from raycast/script-commands
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcurrent-weather.sh
executable file
·32 lines (25 loc) · 1.06 KB
/
current-weather.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/bash
# @raycast.title Current Weather
# @raycast.author Caleb Stauffer
# @raycast.authorURL https://github.com/crstauf
# @raycast.description Get current weather report from [wttr.in](https://wttr.in/).
# @raycast.icon 🌦️
# @raycast.mode inline
# @raycast.packageName Dashboard
# @raycast.schemaVersion 1
## Please be mindful of scalability of wttr.in if adjusting the refresh time:
## currently limited to one million requests per day
## (see https://github.com/chubin/wttr.in/blob/master/share/static/malformed-response.html).
# @raycast.refreshTime 1h
# get your ip
IP=$(dig -4 TXT +short o-o.myaddr.l.google.com @ns1.google.com | sed -r 's/^"|"$//g')
# configure
UNIT="m" # celsius
# UNIT="u" # fahrenheit
# Automatic location
LOCATION=$(curl --silent "https://ipapi.co/${IP}/postal/") # automatic location
CITY=$(curl --silent "https://ipapi.co/${IP}/city/") # for output
# Manual location
# LOCATION="Berlin" # use this if you want to manually set your location
# CITY="${LOCATION}"
curl --silent "https://wttr.in/${LOCATION}?format=${CITY}:+%c+%f+%w&${UNIT}"