dotfiles/i3/scripts/weather.old

52 lines
1.2 KiB
Bash

#!/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=""
color=""
status=0
URL='http://www.accuweather.com/en/es/barcelona/307297/weather-forecast/307297'
SITE="$(torify curl -s "$URL")"
weather="$(echo "$SITE" | awk -F\' '/acm__RecentLocationsCarousel\.push/{print $14 }'| head -1)"
temp="$(echo "$SITE" | awk -F\' '/acm_RecentLocationsCarousel\.push/{print $12"°" }'| head -1)"
if [[ $weather == *thunder* || $weather == *Thunder* ]]; then
icon=""
else
if [[ $weather == *rain* || $weather == *Rain* ]]; then
icon=""
else
if [[ $weather == *cloud* || $weather == *Cloud* ]]; then
icon=""
else
icon=""
fi
fi
fi
full='<span foreground="#729FCF">'"$icon"'</span> '"$temp"
short="$temp"
echo $full
echo $short
echo $color
exit $status