2022-10-08 02:31:35 +02:00
|
|
|
#!/bin/sh
|
|
|
|
# weather module for status/stellar
|
|
|
|
|
|
|
|
# values
|
|
|
|
WEATHER_TERM="speedwm-core -curl-weather"
|
|
|
|
ICON="$1"
|
2022-10-08 12:47:57 +02:00
|
|
|
BUTTON="$(cat /tmp/speedwm-button)"
|
|
|
|
|
|
|
|
case "$TERMINAL" in
|
|
|
|
"") TERMINAL=st
|
|
|
|
esac
|
|
|
|
|
|
|
|
case "$BUTTON" in
|
|
|
|
"3") $TERMINAL speedwm-core -curl-weather ; exit ;;
|
|
|
|
esac
|
2022-10-08 02:31:35 +02:00
|
|
|
|
|
|
|
# check if a forecast exists
|
|
|
|
# status script should create this
|
|
|
|
if [ -e "/tmp/wstatus" ]; then
|
|
|
|
FORECAST="$(cat /tmp/wstatus)"
|
|
|
|
else
|
|
|
|
echo "FATAL: No weather status available!"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# no spacing if there's no icon
|
|
|
|
if [ "$ICON" != "" ]; then
|
|
|
|
ICONSPACING=" " # one character spacing
|
|
|
|
fi
|
|
|
|
|
|
|
|
# send the notification
|
|
|
|
SEND_NOTIF() {
|
|
|
|
FULL_WEATHER="${ICON}${ICONSPACING}$FORECAST"
|
|
|
|
notify-send "$FULL_WEATHER"
|
|
|
|
|
|
|
|
echo "Notification sent successfully!"
|
|
|
|
echo "INFO: $FULL_WEATHER"
|
|
|
|
|
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
|
|
|
|
command -v notify-send > /dev/null && SEND_NOTIF
|
|
|
|
echo "FATAL: libnotify not installed, can't send notification."
|
|
|
|
|
|
|
|
exit 1
|