commit b9f5516a3b83f4e5c7d6facc861a889a4384d15d
Author: Frederic Cambus <fcambus@users.sourceforge.net>
Date: Sat, 19 Oct 2013 13:13:28 +0200
Initial commit
Diffstat:
A | AUTHORS | | | 6 | ++++++ |
A | ChangeLog | | | 3 | +++ |
A | LICENSE | | | 28 | ++++++++++++++++++++++++++++ |
A | ansiweather | | | 120 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
4 files changed, 157 insertions(+), 0 deletions(-)
diff --git a/AUTHORS b/AUTHORS
@@ -0,0 +1,6 @@
+Telize is developed by :
+
+Frederic Cambus <fcambus AT users DOT sourceforge DOT net>
+
+Site : http://www.cambus.net
+Twitter : @fcambus
diff --git a/ChangeLog b/ChangeLog
@@ -0,0 +1,3 @@
+AnsiWeather 1.00 (2013-10-19)
+
+- Initial release
diff --git a/LICENSE b/LICENSE
@@ -0,0 +1,28 @@
+Copyright (c) 2013, Frederic Cambus
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ * Neither the name of AnsiWeather nor the names of its contributors may be
+ used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
diff --git a/ansiweather b/ansiweather
@@ -0,0 +1,120 @@
+#!/bin/bash
+
+###############################################################################
+# #
+# AnsiWeather 1.00 (c) by Frederic Cambus 2013 #
+# https://github.com/fcambus/ansiweather #
+# #
+# Created: 2013/08/29 #
+# Last Updated: 2013/10/19 #
+# #
+# AnsiWeather is released under the BSD 3-Clause license. #
+# See LICENSE file for details. #
+# #
+###############################################################################
+
+
+
+###[ Configuration options ]###################################################
+
+# Location : example "Moscow,RU"
+location="Moscow,RU"
+
+# System of Units : "metric" or "imperial"
+units="metric"
+
+# Display symbols : "true" or "false" (requires an Unicode capable display)
+symbols=true
+
+
+
+#### [ Colors and characters ]#################################################
+
+background="\033[44m"
+text="\033[36;1m"
+data="\033[33;1m"
+delimiter="\033[35m=>"
+dashes="\033[34m-"
+
+
+
+###[ Unicode Symbols for icons ]###############################################
+
+sun="\033[33;1m\xe2\x98\x80"
+moon="\033[36m\xe2\x98\xbd"
+clouds="\033[37;1m\xe2\x98\x81"
+rain="\xe2\x98\x94"
+
+
+
+###[ Fetch Weather data ]######################################################
+
+weather=$(curl -s http://api.openweathermap.org/data/2.5/weather?q=$location\&units=$units)
+
+
+
+###[ Process Weather data ]####################################################
+
+city=$(echo $weather | jq -r '.name')
+temperature=$(echo $weather | jq '.main.temp')
+humidity=$(echo $weather | jq '.main.humidity')
+pressure=$(echo $weather | jq '.main.pressure')
+sky=$(echo $weather | jq -r '.weather[0].main')
+sunrise=$(echo $weather | jq '.sys.sunrise')
+sunset=$(echo $weather | jq '.sys.sunset')
+
+
+
+###[ Set the period ]##########################################################
+
+now=$(date +%s)
+
+if [ $now -ge $sunset ] || [ $now -le $sunrise ]
+then
+ period="night"
+else
+ period="day"
+fi
+
+
+
+###[ Set the scale ]###########################################################
+
+case $units in
+ metric)
+ scale="°C"
+ ;;
+ imperial)
+ scale="°F"
+ ;;
+esac
+
+
+
+###[ Set icons ]###############################################################
+
+if [ $symbols = true ]
+then
+ case $sky in
+ Clear)
+ if [ $period = "night" ]
+ then
+ icon="$moon "
+ else
+ icon="$sun "
+ fi
+ ;;
+ Clouds)
+ icon="$clouds "
+ ;;
+ Rain)
+ icon="$rain "
+ ;;
+ esac
+fi
+
+
+
+###[ Display current Weather ]#################################################
+
+echo -e "$background$text Current weather in $city $delimiter$data $temperature $scale $icon$dashes$text Humidity $delimiter$data $humidity % $dashes$text Pressure $delimiter$data $pressure hPa \033[0m"