From d477b69b5ad96c04bd1b7137f45b2e2b5158309f Mon Sep 17 00:00:00 2001 From: Daniel <89086143+BardofSprites@users.noreply.github.com> Date: Mon, 11 Nov 2024 17:00:08 -0500 Subject: fix formatting --- bin/.local/bin/scripts/status/weather | 38 +++++++++++++++++------------------ 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'bin') diff --git a/bin/.local/bin/scripts/status/weather b/bin/.local/bin/scripts/status/weather index eae0fec..14919ae 100755 --- a/bin/.local/bin/scripts/status/weather +++ b/bin/.local/bin/scripts/status/weather @@ -7,46 +7,46 @@ url="${WTTRURL:-wttr.in}" weatherreport="${XDG_CACHE_HOME:-$HOME/.cache}/weatherreport" # Get a weather report from 'wttr.in' and save it locally. -getforecast() { curl -sf "$url/$LOCATION?M" > "$weatherreport" || exit 1; } +getforecast() { curl -sf "$url/Louisville?M" > "$weatherreport" || exit 1; } # Forecast should be updated only once a day. checkforecast() { - [ -s "$weatherreport" ] && [ "$(stat -c %y "$weatherreport" 2>/dev/null | - cut -d' ' -f1)" = "$(date '+%Y-%m-%d')" ] + [ -s "$weatherreport" ] && [ "$(stat -c %y "$weatherreport" 2>/dev/null | + cut -d' ' -f1)" = "$(date '+%Y-%m-%d')" ] } getprecipchance() { - echo "$weatherdata" | sed '16q;d' | # Extract line 16 from file - grep -wo "[0-9]*%" | # Find a sequence of digits followed by '%' - sort -rn | # Sort in descending order - head -1q # Extract first line + echo "$weatherdata" | sed '16q;d' | # Extract line 16 from file + grep -wo "[0-9]*%" | # Find a sequence of digits followed by '%' + sort -rn | # Sort in descending order + head -1q # Extract first line } getdailyhighlow() { - echo "$weatherdata" | sed '13q;d' | # Extract line 13 from file - grep -o "m\\([-+]\\)*[0-9]\\+" | # Find temperatures in the format "m" - sed 's/[+m]//g' | # Remove '+' and 'm' - sort -g | # Sort in ascending order - sed -e 1b -e '$!d' # Extract the first and last lines + echo "$weatherdata" | sed '13q;d' | # Extract line 13 from file + grep -o "m\\([-+]\\)*[0-9]\\+" | # Find temperatures in the format "m" + sed 's/[+m]//g' | # Remove '+' and 'm' + sort -g | # Sort in ascending order + sed -e 1b -e '$!d' # Extract the first and last lines } readfile() { weatherdata="$(cat "$weatherreport")" ;} showweather() { - readfile - printf "☔%s 🥶%s°C 🌞%s°C\n" "$(getprecipchance)" $(getdailyhighlow) - # printf " %s  %s°C  %s°C\n" "$(getprecipchance)" $(getdailyhighlow) + readfile + printf "☔%s 🥶%s°C 🌞%s°C\n" "$(getprecipchance)" $(getdailyhighlow) + # printf " %s  %s°C  %s°C\n" "$(getprecipchance)" $(getdailyhighlow) } case $BLOCK_BUTTON in - 1) setsid -f "$TERMINAL" -n "floatterm" -c "floatterm" -g "150x35" -e less -Sfr "$weatherreport" ;; - 2) getforecast && showweather ;; - 3) notify-send "🌈 Weather module" "\- Left click for full forecast. + 1) setsid -f "$TERMINAL" -n "floatterm" -c "floatterm" -g "150x35" -e less -Sfr "$weatherreport" ;; + 2) getforecast && showweather ;; + 3) notify-send "🌈 Weather module" "\- Left click for full forecast. - Middle click to update forecast. ☔: Chance of rain/snow 🥶: Daily low 🌞: Daily high" ;; - 6) "$TERMINAL" -e "$EDITOR" "$0" ;; + 6) "$TERMINAL" -e "$EDITOR" "$0" ;; esac checkforecast || getforecast -- cgit v1.2.3