-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathweather
executable file
·49 lines (41 loc) · 1.23 KB
/
weather
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env bash
################################
# Shows info about the weather (in Cincinnati) from accuweather.com
#
# TODO: completely rewrite, probably using openweather APIs
# TODO: make location configurable
# TODO: make temperature unit configurable
#
# @return {Number(degrees Fahrenheit)}: Current temperature in Cincinnati
################################
dir=$(dirname $0)
source $dir/util.sh
full=""
short=""
status=0
URL='http://www.accuweather.com/en/us/cincinnati-oh/45212/weather-forecast/350126'
SITE="$(curl -s "$URL")"
weather="$(echo "$SITE" | awk -F\' '/acm_RecentLocationsCarousel\.push/{print $13 }'| head -1)"
temp="$(echo "$SITE" | awk -F\' '/acm_RecentLocationsCarousel\.push/{print $10 }'| head -1)"
if [[ $weather == *thunder* || $weather == *Thunder* ]]; then
icon=""
else
if [[ $weather == *rain* || $weather == *Rain* ]]; then
icon=""
else
if [[ $weather == *snow* || $weather == *Snow* ]]; then
icon="❄"
else
if [[ $weather == *cloud* || $weather == *Cloud* ]]; then
icon=""
else
icon=""
fi
fi
fi
fi
full="$icon $temp°"
short="$temp°"
echo $full
echo $short
exit $status