Adding moon phase module
This commit is contained in:
parent
ae8a57afdc
commit
e939d54eaf
@ -3,13 +3,12 @@ from i3pystatus import IntervalModule, formatp
|
|||||||
import datetime
|
import datetime
|
||||||
import math
|
import math
|
||||||
import decimal
|
import decimal
|
||||||
#import ephem
|
|
||||||
import os
|
import os
|
||||||
from i3pystatus.core.util import TimeWrapper
|
from i3pystatus.core.util import TimeWrapper
|
||||||
|
|
||||||
|
|
||||||
dec = decimal.Decimal
|
dec = decimal.Decimal
|
||||||
|
|
||||||
|
|
||||||
# Moon phase module
|
# Moon phase module
|
||||||
class MoonPhase(IntervalModule):
|
class MoonPhase(IntervalModule):
|
||||||
|
|
||||||
@ -28,8 +27,6 @@ class MoonPhase(IntervalModule):
|
|||||||
Last Quarter:
|
Last Quarter:
|
||||||
Waning Crescent:
|
Waning Crescent:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
settings = (
|
settings = (
|
||||||
@ -44,7 +41,6 @@ class MoonPhase(IntervalModule):
|
|||||||
|
|
||||||
interval = 60 * 60 * 2 # every 2 hours
|
interval = 60 * 60 * 2 # every 2 hours
|
||||||
|
|
||||||
|
|
||||||
status = {
|
status = {
|
||||||
|
|
||||||
"New Moon": "NM",
|
"New Moon": "NM",
|
||||||
@ -69,7 +65,6 @@ class MoonPhase(IntervalModule):
|
|||||||
"Waning Crescent": "#FF341F",
|
"Waning Crescent": "#FF341F",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def pos(now=None):
|
def pos(now=None):
|
||||||
now = None
|
now = None
|
||||||
days_in_second = 86400
|
days_in_second = 86400
|
||||||
@ -85,7 +80,6 @@ class MoonPhase(IntervalModule):
|
|||||||
|
|
||||||
return lunarCycle % dec(1)
|
return lunarCycle % dec(1)
|
||||||
|
|
||||||
|
|
||||||
def current_phase(self):
|
def current_phase(self):
|
||||||
|
|
||||||
lunarCycle = self.pos()
|
lunarCycle = self.pos()
|
||||||
@ -109,7 +103,6 @@ class MoonPhase(IntervalModule):
|
|||||||
lunarCycle = float(self.pos()) * 100
|
lunarCycle = float(self.pos()) * 100
|
||||||
|
|
||||||
if lunarCycle > 50:
|
if lunarCycle > 50:
|
||||||
|
|
||||||
phase = 100 - lunarCycle
|
phase = 100 - lunarCycle
|
||||||
|
|
||||||
else:
|
else:
|
||||||
@ -119,15 +112,12 @@ class MoonPhase(IntervalModule):
|
|||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
|
||||||
|
|
||||||
fdict = {
|
fdict = {
|
||||||
"status": self.status[self.current_phase()],
|
"status": self.status[self.current_phase()],
|
||||||
"illum": self.illum(),
|
"illum": self.illum(),
|
||||||
#"phase_color": self.phase_color[self.current_phase()],
|
|
||||||
}
|
}
|
||||||
|
|
||||||
self.output = {
|
self.output = {
|
||||||
"full_text": formatp(self.format, **fdict),
|
"full_text": formatp(self.format, **fdict),
|
||||||
"color": self.phase_color[self.current_phase()],
|
"color": self.phase_color[self.current_phase()],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user