mirror of
https://github.com/arthur-pbty/arthur-os.git
synced 2026-08-01 20:28:16 +02:00
* Add live weather * Just use jq * Add Weather app and make it click target * Simplify * Looks better * Nicer flow * Simplify * Move to using the notification instead of tooltip * No longer needed
27 lines
673 B
Bash
Executable File
27 lines
673 B
Bash
Executable File
#!/bin/bash
|
|
|
|
# omarchy:summary=Returns a formatted weather status string with temperature and wind speed.
|
|
|
|
weather=$(curl -fsS --max-time 4 "https://wttr.in?format=%l|%t|%w" 2>/dev/null | tr -d '\n')
|
|
|
|
if [[ -z $weather ]]; then
|
|
echo "Weather unavailable"
|
|
exit 1
|
|
fi
|
|
|
|
IFS='|' read -r place temperature wind <<< "$weather"
|
|
place=${place%%,*}
|
|
place=${place^}
|
|
format_temperature() {
|
|
local celsius=${1#+}
|
|
celsius=${celsius//°/}
|
|
celsius=${celsius%C}
|
|
|
|
echo "${celsius}°c / $((celsius * 9 / 5 + 32))°f"
|
|
}
|
|
|
|
temperature=$(format_temperature "$temperature")
|
|
wind=${wind//km\// km/}
|
|
|
|
echo "$(omarchy-weather-icon) $place · Temperature $temperature · Wind $wind"
|