This commit is contained in:
Jimbo 2024-09-13 15:22:16 -04:00
parent 2517daec9e
commit 5a65bbd4bc

View file

@ -204,15 +204,15 @@
weatherModule = { weatherModule = {
exec = pkgs.writeScript "weatherScript" '' exec = pkgs.writeScript "weatherScript" ''
# Fetch weather data # Fetch weather data
fetch=$(fastfetch -c all -s weather -l none) fetch=$(fastfetch -c all -s weather -l none | sed -E 's/Weather: ([^ ]+) - ([^ ]+ [^ ]+) (\(.*\))/\1\n\2\n\3/' | sed 's/^\+//')
temp=$(echo $fetch | awk '{print $2}' | sed 's/^\+//') temp=$(echo "$fetch" | sed -n '1p')
condition=$(echo $fetch | awk '{print $4}') condition=$(echo "$fetch" | sed -n '2p')
city=$(echo "$fetch" | awk '{print $5}' | sed 's/[(),]//g') location=$(echo "$fetch" | sed -n '3p' | sed 's/[()]//g')
# Map weather conditions to emojis # Map weather conditions to emojis
case "$condition" in case "$condition" in
"Clear"|"Sunny") emoji="";; "Clear"|"Sunny") emoji="";;
"Clouds") emoji="";; "Cloudy"|"Partly cloudy") emoji="";;
"Rain") emoji="🌧";; "Rain") emoji="🌧";;
"Drizzle") emoji="🌦";; "Drizzle") emoji="🌦";;
"Thunderstorm") emoji="";; "Thunderstorm") emoji="";;
@ -222,7 +222,7 @@
esac esac
# Display weather emoji and temperature # Display weather emoji and temperature
echo {\"text\":\"$emoji $temp\",\"tooltip\":\"$city: $condition\"} echo {\"text\":\"$emoji $temp\",\"tooltip\":\"$location: $condition\"}
''; '';
format = "<span font_size='11pt'>{}</span>"; format = "<span font_size='11pt'>{}</span>";
return-type = "json"; return-type = "json";