nexoniarz-config-nixos-laptop/modules/scripts/weather-fetch.sh
Nexoniarz 6bcd5e15ad Switch desktop environment from Hyprland to Pantheon
Configures Pantheon (LightDM + gala) for daily use on this ASUS TUF
Gaming A15 (FA507NU), and drops everything that only existed to serve
the previous Hyprland/Quickshell setup:

- desktop.nix: services.desktopManager.pantheon instead of
  programs.hyprland + greetd; comfy laptop touchpad defaults.
- drivers.nix: NVIDIA PRIME render offload between the AMD Radeon 680M
  (drives the panel) and the RTX 4050 Max-Q (offload-only), using this
  machine's real PCI bus IDs; asusd/supergfxd for ASUS-specific laptop
  control.
- apps.nix / scripts.nix: removed Hyprland/Quickshell-only packages and
  scripts (kitty, rofi, quickshell, mako, hyprlock, hyprpaper/mpvpaper,
  the Quickshell theme-picker scripts, cursor/wallpaper/display
  helpers) — Pantheon ships its own Files/Terminal/Screenshot/
  notifications/theming natively. Kept the DE-agnostic scripts (vault
  toggle, metadata stripping, brightness control, Wi-Fi hotspot,
  telemetry, weather).
- theme.nix and default-apps.nix deleted entirely — Pantheon owns
  GTK/icon theming itself, no more live dconf/CSS generation pipeline
  needed.
- Deleted hyprland/ and dotfiles/ (kitty, mako, quickshell, rofi).

Verified with `nixos-rebuild build`.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RpiovBQL6k5MTDMN3Ln9nL
2026-08-31 19:52:59 +02:00

32 lines
1.4 KiB
Shell
Executable file

#!/usr/bin/env bash
# Fetches current weather + a short hourly forecast from Open-Meteo (free,
# no API key/account needed) for either the machine's IP-geolocated
# position (default, via ip-api.com — also free/keyless) or an explicitly
# named city, and prints one combined JSON object.
set -euo pipefail
city="${1:-}"
if [ -n "$city" ]; then
encoded="$(jq -sRr @uri <<< "$city")"
geo="$(curl -s "https://geocoding-api.open-meteo.com/v1/search?count=1&name=$encoded")"
lat="$(jq -r '.results[0].latitude // empty' <<< "$geo")"
lon="$(jq -r '.results[0].longitude // empty' <<< "$geo")"
place="$(jq -r '.results[0].name // empty' <<< "$geo")"
country="$(jq -r '.results[0].country // empty' <<< "$geo")"
else
ipgeo="$(curl -s "http://ip-api.com/json/")"
lat="$(jq -r '.lat // empty' <<< "$ipgeo")"
lon="$(jq -r '.lon // empty' <<< "$ipgeo")"
place="$(jq -r '.city // empty' <<< "$ipgeo")"
country="$(jq -r '.country // empty' <<< "$ipgeo")"
fi
if [ -z "$lat" ] || [ -z "$lon" ]; then
echo '{"error":"location lookup failed"}'
exit 0
fi
weather="$(curl -s "https://api.open-meteo.com/v1/forecast?latitude=$lat&longitude=$lon&current=temperature_2m,weather_code,wind_speed_10m,precipitation&hourly=temperature_2m,weather_code,precipitation_probability&timezone=auto&forecast_days=2")"
jq --arg place "$place" --arg country "$country" '. + {place: $place, country: $country}' <<< "$weather"