myhome/.local/bin/sb-weather

8 lines
559 B
Bash
Executable File

#!/bin/bash
print_weather() {
[ "$(stat -c %y "/home/yorune/.config/weatherreport" 2>/dev/null | cut -d' ' -f1)" != "$(date '+%Y-%m-%d')" ] && curl -s "wttr.in/$location" > "/home/yorune/.config/weatherreport"
printf "%s" "$(sed '16q;d' "/home/yorune/.config/weatherreport" | grep -wo "[0-9]*%" | sort -n | sed -e '$!d' | sed -e "s/^/☔ /g" | tr -d '\n')" && sed '13q;d' "/home/yorune/.config/weatherreport" | grep -o "m\\(-\\)*[0-9]\\+" | sort -n -t 'm' -k 2n | sed -e 1b -e '$!d' | tr '\n|m' ' ' | awk '{print" ❄",$1"°","☀",$2"°"}'
}
print_weather