Renamed folder Scripts to scripts

This commit is contained in:
Markus Fleschutz
2023-10-31 11:32:46 +01:00
parent f826630e72
commit 66af9a5668
598 changed files with 304 additions and 304 deletions

47
scripts/ping-weather.ps1 Executable file
View File

@@ -0,0 +1,47 @@
<#
.SYNOPSIS
Ping the currrent weather conditions
.DESCRIPTION
This PowerShell script continuously shows the current weather conditions (similar to htop, 10 min update interval by default).
.PARAMETER Location
Specifies the location to use (determined automatically per default)
.EXAMPLE
PS> ./ping-weather
Current weather conditions at Paris (Ile-de-France), updating every 10 min...
🕗10:24 AM UTC 🌡23°C ☂0.0mm 💨9km/h from S ☁0% 💧41% ☀UV6 1020hPa Sunny
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
param([string]$Location = "", [int]$UpdateInterval = 600)
try {
$Weather = (Invoke-WebRequest -URI http://wttr.in/${Location}?format=j1 -userAgent "curl" -useBasicParsing).Content | ConvertFrom-Json
$Area = $Weather.nearest_area.areaName.value
$Region = $Weather.nearest_area.region.value
"Current weather conditions at $Area ($Region), updating every $($UpdateInterval / 60) min..."
do {
$Description = $Weather.current_condition.WeatherDesc.value
$TempC = $Weather.current_condition.temp_C
$PrecipMM = $Weather.current_condition.precipMM
$WindSpeed = $Weather.current_condition.windspeedKmph
$WindDir = $Weather.current_condition.winddir16Point
$Clouds = $Weather.current_condition.cloudcover
$Humidity = $Weather.current_condition.humidity
$UV = $Weather.current_condition.uvIndex
$Visib = $Weather.current_condition.visibility
$Pressure = $Weather.current_condition.pressure
$Time = $Weather.current_condition.observation_time
"🕗$Time UTC 🌡$($TempC)°C ☂️$($PrecipMM)mm 💨$($WindSpeed)km/h from $WindDir ☁️$($Clouds)% 💧$($Humidity)% ☀UV$UV 👀$($Visib)km $($Pressure)hPa $Description"
Start-Sleep -s $UpdateInterval
$Weather = (Invoke-WebRequest -URI http://wttr.in/${Location}?format=j1 -userAgent "curl" -useBasicParsing).Content | ConvertFrom-Json
} while ($true)
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}