26 lines
701 B
Plaintext
Raw Permalink Normal View History

2026-03-09 00:07:31 -04:00
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_NAME=$(basename "${BASH_SOURCE[0]}")
WEATHER="/tmp/wttr.in"
CONFIG="$XDG_CONFIG_HOME/fastfetch/small.jsonc"
log() {
logger -i -t "$SCRIPT_NAME" "$*"
}
main() {
TIME=$(date +%H:%M)
if [[ "$TIME" < "12:00" ]] && [[ "$TIME" > "00:00" ]]; then
log "Getting weather and sunrise time."
curl -s wttr.in/hartford\?format="%c\n%t\n%S\n" > "$WEATHER"
else
log "Getting weather and sunset time."
curl -s wttr.in/hartford\?format="%c\n%t\n%s\n" > "$WEATHER"
fi
CURRENT=$(cat "$WEATHER")
CONDITION=$(echo "$CURRENT" | head -n 1 | perl -CS -pe 's/\x{FE0F}//g' | tr -d '[:space:]' | xargs) envsubst < "$CONFIG" > /tmp/small.jsonc
}
main