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 +}