This is a modified sxmo_waether.sh script to include worldwide functionality.
Signed-off-by: hazardchem <pthom44@live.com.au>
---
scripts/README.md | 5 +++++
scripts/sxmo_weather.sh | 45 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 50 insertions(+)
create mode 100755 scripts/sxmo_weather.sh
diff --git a/scripts/README.md b/scripts/README.md
index 63096aa..6fef6cd 100644
--- a/scripts/README.md
+++ b/scripts/README.md
@@ -104,3 +104,8 @@ Copy the script to `$XDG_CONFIG_HOME/sxmo/userscripts` and make it executable.
- Author: Peter Thomason <pthom44@live.com.au>
- Licence: GPL3+
- Description: passmenu tailored for sxmo.
+
+## sxmo_weather.sh
+- Author: Peter Thomason <pthom44@live.com.au>
+- Licence: GPL3+
+- Description: Modified sxmo_weather.sh to include worldwide support. This supports current location and future forcasts.
diff --git a/scripts/sxmo_weather.sh b/scripts/sxmo_weather.sh
new file mode 100755
index 0000000..524136b
--- /dev/null
+++ b/scripts/sxmo_weather.sh
@@ -0,0 +1,45 @@
+#!/bin/sh
+# SPDX-License-Identifier: AGPL-3.0-only
+# Copyright 2022 Sxmo Contributors
+# title="$icon_wtr Weather"
+# include common definitions
+# shellcheck source=scripts/core/sxmo_common.sh
+. sxmo_common.sh
+
+[ -z "$SXMO_GPSLOCATIONSFILES" ] && SXMO_GPSLOCATIONSFILES="$(xdg_data_path sxmo/appcfg/places_for_gps.tsv)"
+LOCATIONS="$(cat $SXMO_GPSLOCATIONSFILES)"
+
+WEATHERMENU() {
+ CHOICE="$(
+ printf %b "$(
+ echo "Close Menu\nCurrent Location";
+ echo "$LOCATIONS"
+ )" |
+ grep -vE '^#' |
+ sed "s/\t/: /g" |
+ sxmo_dmenu_with_kb.sh -i -c -l 10 -p "Locations"
+ )" || exit 0
+ if [ "$CHOICE" = "Close Menu" ]; then
+ exit 0
+ else
+ OUTPUT="$(echo "Close Menu" | sed 's/$/\nRight Now\nForecast/' | sxmo_dmenu.sh -i -l 10 )" || exit 0
+ if [ "$CHOICE" = "Current Location" ]; then
+ PLACE=""
+ else
+ PLACE="$(echo "$CHOICE" | cut -d ',' -f 1 | sed s'/ /+/g')"
+ fi
+ case "$OUTPUT" in
+ "Close Menu")
+ exit 0
+ ;;
+ "Right Now")
+ WEATHER="$(curl wttr.in/$PLACE?format=4)"
+ notify-send "$WEATHER"
+ ;;
+ "Forecast")
+ sxmo_terminal.sh -f "monospace:size=5" sh -c "curl http://wttr.in/$PLACR | less -SR"
+ ;;
+ esac
+ fi
+}
+WEATHERMENU
--
2.40.0