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