Read calendards URL from .cals file

This commit is contained in:
nemunaire 2022-08-14 19:55:12 +02:00
parent 8c7d5f583e
commit 5acdf32ae7
3 changed files with 11 additions and 4 deletions

View File

@ -71,7 +71,7 @@ def main():
# ical
from modules.ical import IcalModule
cal = IcalModule().draw_module(config, 480-int(480/1.6), 255)
cal = IcalModule(config).draw_module(config, 480-int(480/1.6), 255)
image.paste(cal, (0, 250))
# Toolbar

View File

@ -5,7 +5,7 @@ from PIL import Image, ImageDraw, ImageFont
class Config:
def __init__(self):
def __init__(self, cals_file_list=".cals"):
if os.path.exists('/usr/share/fonts/source-pro/'):
self.fnt_R_path = "/usr/share/fonts/source-pro/SourceSansPro-Regular.otf"
self.fnt_RI_path = "/usr/share/fonts/source-pro/SourceSansPro-It.otf"
@ -19,6 +19,13 @@ class Config:
self.fnt_RI_path = "/usr/share/fonts/TTF/LinBiolinum_RIah.ttf"
self.fnt_RB_path = "/usr/share/fonts/TTF/LinBiolinum_RBah.ttf"
try:
with open(cals_file_list) as f:
self.cals = [c for c in f.read().split("\n") if len(c) > 0]
except:
print("No calendar found. Please create a file " + cals_file_list)
self.cals = []
self.css_overlay = NamedTemporaryFile()
with open(self.css_overlay.name, 'w') as f:
f.write('''

View File

@ -7,8 +7,8 @@ import pytz
class IcalModule:
def __init__(self, cals=[]):
self.cals = cals
def __init__(self, config):
self.cals = config.cals
def draw_module(self, config, width, height, line_height=19):
now = datetime.now(tz=pytz.timezone('Europe/Paris'))