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:
@@ -105,6 +105,7 @@ in {
|
|||||||
import astral
|
import astral
|
||||||
import astral.moon
|
import astral.moon
|
||||||
import astral.sun
|
import astral.sun
|
||||||
|
import math
|
||||||
|
|
||||||
moon_phases = {
|
moon_phases = {
|
||||||
0: "🌑",
|
0: "🌑",
|
||||||
@@ -120,10 +121,12 @@ in {
|
|||||||
current_phase = astral.moon.phase()
|
current_phase = astral.moon.phase()
|
||||||
closest_phase = min(moon_phases.keys(), key=lambda x: abs(current_phase - x))
|
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})
|
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)
|
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))
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user