From 997dfdd04eadaa71e7188d573dd684d10576e4f3 Mon Sep 17 00:00:00 2001 From: Jus de Patate Date: Mon, 4 Feb 2019 14:05:19 +0100 Subject: [PATCH] Add new plugin : wttr Based on an old script by meh : https://github.com/jusdepatate/wttr.sh --- plugins/available/wttr.plugin.bash | 39 ++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 plugins/available/wttr.plugin.bash diff --git a/plugins/available/wttr.plugin.bash b/plugins/available/wttr.plugin.bash new file mode 100644 index 00000000..45fe75d3 --- /dev/null +++ b/plugins/available/wttr.plugin.bash @@ -0,0 +1,39 @@ +function wttr() { +if [ -n "$1" ]; then + if [ "$(ping -c 1 wttr.in)" ]; then + if [ "$(which curl 2>/dev/null)" ]; then + CITY="$(curl -s ipinfo.io/city)" + echo "Weather of $1" + echo " " + curl -s "wttr.in/$1?Q0" + elif [ "$(which wget 2>/dev/null)" ]; then + CITY="$(wget -qO- ipinfo.io/city)" + echo "Weather of $1" + echo " " + wget -qO- "wttr.in/$1?Q0" + fi + echo " " + else + echo "Can't connect to wttr.in" + exit 1 + fi +else + if [ "$(ping -c 1 wttr.in)" ]; then + if [ "$(which curl 2>/dev/null)" ]; then + CITY="$(curl -s ipinfo.io/city)" + echo "Weather of $CITY" + echo " " + curl -s "wttr.in/$CITY?Q0" + elif [ "$(which wget 2>/dev/null)" ]; then + CITY="$(wget -qO- ipinfo.io/city)" + echo "Weather of $CITY" + echo " " + wget -qO- "wttr.in/$CITY?Q0" + fi + echo + else + echo "Can't connect to wttr.in" + exit 1 + fi +fi +}