Skip to content

Instantly share code, notes, and snippets.

@Maffsie
Created January 4, 2010 00:11
Show Gist options
  • Save Maffsie/268201 to your computer and use it in GitHub Desktop.
Save Maffsie/268201 to your computer and use it in GitHub Desktop.
Current conditions as of 9:50 PM GMT
Fair
Feels Like:
-3 °C
Barometer:
1,015.92 mb and steady
Humidity:
91 %
Visibility:
9.99 km
Dewpoint:
-4 °C
Wind:
WNW 11.27 km/h
Sunrise:
8:45 AM
Sunset:
3:47 PM
-3°
#!/bin/bash
#Czyta dane z pliku
cnd=$(cat ~/weather)
snset=`cat ~/weather | tail -n4 | head -n1 | sed s/\ //g | php -r 'echo mktime(file_get_contents("php://stdin"));'`
snrise=`cat ~/weather | tail -n6 | head -n1 | sed s/\ //g | php -r 'echo mktime(file_get_contents("php://stdin"));'`
time=`php -r 'echo time();'`
#Ustawia czcionkę obrazkową, odpowiadającą aktualnej pogoda.
if echo "$cnd" | grep -E -i -q 'partly cloudy'; then
if (($time > $snset || $time < $snrise)); then
echo 'C'
else
echo 'c'
fi
elif echo "$cnd" | grep -E -i -q 'cloudy'; then
echo 'e'
elif echo "$cnd" | grep -E -i -q 'fair|sunny'; then
if (($time > $snset || $time < $snrise)); then
echo 'A'
else
echo 'a'
fi
elif echo "$cnd" | grep -E -i -q 'cloudy'; then
echo 'e'
elif echo "$cnd" | grep -E -i -q 'heavy snow'; then
echo 'q'
elif echo "$cnd" | grep -E -i -q 'light snow'; then
echo 'o'
elif echo "$cnd" | grep -E -i -q 'snow'; then
echo 'p'
elif echo "$cnd" | grep -E -i -q 'heavy rain'; then
if (($time > $snset || $time < $snrise)); then
echo 'j'
else
echo 'i'
fi
elif echo "$cnd" | grep -E -i -q 'rain'; then
if (($time > $snset || $time < $snrise)); then
echo 'G'
else
echo 'g'
fi
elif echo "$cnd" | grep -E -i -q 'heavy shower'; then
echo 'x'
elif echo "$cnd" | grep -E -i -q 'light shower'; then
echo 'r'
elif echo "$cnd" | grep -E -i -q 'shower'; then
echo 's'
elif echo "$cnd" | grep -E -i -q 'lightning'; then
echo 'm'
elif echo "$cnd" | grep -E -i -q 'storm|thunder'; then
echo 'n'
else
echo 'w'
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment