Files
David Heinemeier Hansson dad2870f58 Check for weather once a minute instead of once every ten
More accurate and deals with the first-boot issue on network too
2026-05-08 21:44:21 +02:00

30 lines
898 B
Bash

echo "Add weather widget to Waybar"
WAYBAR_CONFIG="$HOME/.config/waybar/config.jsonc"
WAYBAR_STYLE="$HOME/.config/waybar/style.css"
if [[ -f $WAYBAR_CONFIG ]]; then
if ! grep -q '"custom/weather"' "$WAYBAR_CONFIG"; then
sed -i 's/"modules-center": \["clock",/"modules-center": ["clock", "custom\/weather",/' "$WAYBAR_CONFIG"
sed -i '/"network": {/i\ "custom/weather": {\n "exec": "$OMARCHY_PATH/default/waybar/weather.sh",\n "return-type": "json",\n "interval": 60,\n "tooltip": false,\n "on-click": "notify-send -u low \\"$(omarchy-weather-status)\\""\n },' "$WAYBAR_CONFIG"
fi
fi
if [[ -f $WAYBAR_STYLE ]] && ! grep -q '#custom-weather' "$WAYBAR_STYLE"; then
cat >>"$WAYBAR_STYLE" <<'EOF'
#custom-weather {
margin-left: 7.5px;
margin-right: 7.5px;
}
#custom-weather.unavailable {
min-width: 0;
margin: 0;
padding: 0;
}
EOF
fi
omarchy-restart-waybar