speedwm-personal/modules/module_weather
speediegq 38caf833c8 Add net status, modify existing modules to use previous commit, use
wildcards in Makefile, not sure why I haven't done this earlier
2022-10-08 12:47:57 +02:00

46 lines
881 B
Bash
Executable file

#!/bin/sh
# weather module for status/stellar
# values
WEATHER_TERM="speedwm-core -curl-weather"
ICON="$1"
BUTTON="$(cat /tmp/speedwm-button)"
case "$TERMINAL" in
"") TERMINAL=st
esac
case "$BUTTON" in
"3") $TERMINAL speedwm-core -curl-weather ; exit ;;
esac
# 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