Adding moon phase module
This commit is contained in:
parent
78d9bdda27
commit
f8223286e0
@ -2,8 +2,10 @@ from i3pystatus import IntervalModule, formatp
|
||||
|
||||
import datetime
|
||||
import math
|
||||
|
||||
import decimal
|
||||
import os
|
||||
|
||||
from i3pystatus.core.util import TimeWrapper
|
||||
|
||||
dec = decimal.Decimal
|
||||
@ -11,22 +13,19 @@ dec = decimal.Decimal
|
||||
|
||||
# Moon phase module
|
||||
class MoonPhase(IntervalModule):
|
||||
|
||||
"""
|
||||
Available Formatters
|
||||
|
||||
status: Allow for mapping of current moon phase
|
||||
status {
|
||||
status: Allows for mapping of current moon phase to various
|
||||
- New Moon:
|
||||
- Waxing Crescent:
|
||||
- First Quarter:
|
||||
- Waxing Gibbous:
|
||||
- Full Moon:
|
||||
- Waning Gibbous:
|
||||
- Last Quarter:
|
||||
- Waning Crescent:
|
||||
|
||||
New Moon:
|
||||
Waxing Crescent:
|
||||
First Quarter:
|
||||
Waxing Gibbous:
|
||||
Full Moon:
|
||||
Waning Gibbous:
|
||||
Last Quarter:
|
||||
Waning Crescent:
|
||||
}
|
||||
"""
|
||||
|
||||
settings = (
|
||||
@ -54,9 +53,7 @@ class MoonPhase(IntervalModule):
|
||||
|
||||
}
|
||||
|
||||
color = "#ffffff"
|
||||
|
||||
phase_color = {
|
||||
color = {
|
||||
"New Moon": "#00BDE5",
|
||||
"Waxing Crescent": "#138DD8",
|
||||
"First Quarter": "#265ECC",
|
||||
@ -68,16 +65,12 @@ class MoonPhase(IntervalModule):
|
||||
}
|
||||
|
||||
def pos(now=None):
|
||||
now = None
|
||||
days_in_second = 86400
|
||||
|
||||
if now is None:
|
||||
now = datetime.datetime.now()
|
||||
|
||||
difference = now - datetime.datetime(2001, 1, 1)
|
||||
|
||||
days = dec(difference.days) + (dec(difference.seconds) / dec(days_in_second))
|
||||
|
||||
lunarCycle = dec("0.20439731") + (days * dec("0.03386319269"))
|
||||
|
||||
return lunarCycle % dec(1)
|
||||
@ -114,8 +107,6 @@ class MoonPhase(IntervalModule):
|
||||
|
||||
def run(self):
|
||||
|
||||
color = self.color
|
||||
|
||||
fdict = {
|
||||
"status": self.status[self.current_phase()],
|
||||
"illum": self.illum(),
|
||||
@ -123,5 +114,5 @@ class MoonPhase(IntervalModule):
|
||||
|
||||
self.output = {
|
||||
"full_text": formatp(self.format, **fdict),
|
||||
"color": self.phase_color[self.current_phase()],
|
||||
"color": self.color[self.current_phase()],
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user