diff --git a/home-manager/sway/waybar.nix b/home-manager/sway/waybar.nix index 54804ef..58e305e 100644 --- a/home-manager/sway/waybar.nix +++ b/home-manager/sway/waybar.nix @@ -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 = "{}"; return-type = "json";