1
0
mirror of https://github.com/kmein/niveum synced 2026-03-16 10:11:08 +01:00

feat(i3status-rust): show moon fullness percentage

This commit is contained in:
2021-11-20 09:40:32 +01:00
parent 82b9bb2a4c
commit 416d3ab277

View File

@@ -105,6 +105,7 @@ in {
import astral
import astral.moon
import astral.sun
import math
moon_phases = {
0: "🌑",
@@ -120,10 +121,12 @@ in {
current_phase = astral.moon.phase()
closest_phase = min(moon_phases.keys(), key=lambda x: abs(current_phase - x))
moon_percentage = round(100 * math.sin(current_phase / 28 * math.pi), 1)
city = astral.LocationInfo("Berlin", "Germany", "${spacetime.time.timeZone}", ${toString spacetime.location.latitude}, ${toString spacetime.location.longitude})
sun = astral.sun.sun(city.observer, date=astral.today(), tzinfo=city.timezone)
print("🌅 {} 🌇 {} {}".format(sun["sunrise"].strftime("%R"), sun["sunset"].strftime("%R"), moon_phases[closest_phase]))
print("🌅 {} 🌇 {} {} {}%".format(sun["sunrise"].strftime("%R"), sun["sunset"].strftime("%R"), moon_phases[closest_phase], moon_percentage))
'';
}
{