waybar updates
This commit is contained in:
@@ -63,6 +63,9 @@ weather = requests.get("https://wttr.in/?format=j1").json()
|
||||
|
||||
|
||||
def format_time(time):
|
||||
return datetime.strptime(format_24_time(time), "%H").strftime("%I %p")
|
||||
|
||||
def format_24_time(time):
|
||||
return time.replace("00", "").zfill(2)
|
||||
|
||||
|
||||
@@ -105,10 +108,10 @@ data["text"] = (
|
||||
)
|
||||
|
||||
data["tooltip"] = (
|
||||
f"<b>{weather['current_condition'][0]['weatherDesc'][0]['value']} {weather['current_condition'][0]['temp_C']}°</b>\n"
|
||||
f"<b>{weather['current_condition'][0]['weatherDesc'][0]['value']} {weather['current_condition'][0]['temp_F']}°</b>\n"
|
||||
)
|
||||
data["tooltip"] += f"Feels like: {weather['current_condition'][0]['FeelsLikeF']}°\n"
|
||||
data["tooltip"] += f"Wind: {weather['current_condition'][0]['windspeedKmph']}Km/h\n"
|
||||
data["tooltip"] += f"Wind: {weather['current_condition'][0]['windspeedMiles']}mph\n"
|
||||
data["tooltip"] += f"Humidity: {weather['current_condition'][0]['humidity']}%\n"
|
||||
for i, day in enumerate(weather["weather"]):
|
||||
data["tooltip"] += f"\n<b>"
|
||||
@@ -116,14 +119,15 @@ for i, day in enumerate(weather["weather"]):
|
||||
data["tooltip"] += "Today, "
|
||||
if i == 1:
|
||||
data["tooltip"] += "Tomorrow, "
|
||||
data["tooltip"] += f"{day['date']}</b>\n"
|
||||
date = datetime.strptime(day['date'], "%Y-%m-%d").strftime("%a %b %d %Y")
|
||||
data["tooltip"] += f"{date}</b>\n"
|
||||
data["tooltip"] += f"⬆️ {day['maxtempF']}° ⬇️ {day['mintempF']}° "
|
||||
data[
|
||||
"tooltip"
|
||||
] += f"🌅 {day['astronomy'][0]['sunrise']} 🌇 {day['astronomy'][0]['sunset']}\n"
|
||||
] += f"☀️ {day['astronomy'][0]['sunrise']} 🌕 {day['astronomy'][0]['sunset']}\n"
|
||||
for hour in day["hourly"]:
|
||||
if i == 0:
|
||||
if int(format_time(hour["time"])) < datetime.now().hour - 2:
|
||||
if int(format_24_time(hour["time"])) < datetime.now().hour - 2:
|
||||
continue
|
||||
data[
|
||||
"tooltip"
|
||||
|
||||
Reference in New Issue
Block a user