remove unnecessary config

This commit is contained in:
2025-11-30 21:32:21 +01:00
parent 8b99fc33ac
commit 6bd7d39351

View File

@@ -66,22 +66,6 @@ class Today(inkycal_module):
name = "Today - Show today's date and events from iCalendars"
optional = {
"week_starts_on": {
"label": "When does your week start? (default=Monday)",
"options": ["Monday", "Sunday"],
"default": "Monday",
},
"show_events": {
"label": "Show parsed events? (default = True)",
"options": [True, False],
"default": True,
},
"ical_urls": {
"label": "iCalendar URL/s, separate multiple ones with a comma",
},
"ical_files": {
"label": "iCalendar filepaths, separated with a comma",
},
"date_format": {
"label": "Use an arrow-supported token for custom date formatting "
+ "see https://arrow.readthedocs.io/en/stable/#supported-tokens, e.g. D MMM",
@@ -92,6 +76,22 @@ class Today(inkycal_module):
+ "see https://arrow.readthedocs.io/en/stable/#supported-tokens, e.g. HH:mm",
"default": "HH:mm",
},
"webdav_hostname": {
"label": "WebDAV Hostname (e.g. https://webdav.server.com)",
"default": "",
},
"webdav_login": {
"label": "WebDAV Login Username",
"default": "",
},
"webdav_password": {
"label": "WebDAV Login Password",
"default": "",
},
"webdav_file_path": {
"label": "WebDAV File Path to Super Productivity JSON file",
"default": "",
},
}
def __init__(self, config):
@@ -112,31 +112,24 @@ class Today(inkycal_module):
self.time_format = config['time_format']
self.language = config['language']
if config['ical_urls'] and isinstance(config['ical_urls'], str):
self.ical_urls = config['ical_urls'].split(',')
else:
self.ical_urls = config['ical_urls']
if config['ical_files'] and isinstance(config['ical_files'], str):
self.ical_files = config['ical_files'].split(',')
else:
self.ical_files = config['ical_files']
# webdav configuration
self.webdav_options = {
'webdav_hostname': config.get('webdav_hostname', ''),
'webdav_login': config.get('webdav_login', ''),
'webdav_password': config.get('webdav_password', ''),
'webdav_file_path': config.get('webdav_file_path', ''),
}
# additional configuration
self.timezone = get_system_tz()
# 选择字体:优先使用支持中文的 NotoSansCJK否则使用 NotoSans
self._font_family = self._select_font_family()
self.num_font = ImageFont.truetype(
fonts[self._font_family], size=self.fontsize
)
# give an OK message
logger.debug(f'{__name__} loaded')
def _select_font_family(self) -> str:
"""选择合适的字体族(支持中文优先)"""
# 优先级NotoSansCJKsc (支持中文) > NotoSans
preferred_fonts = [
'NotoSansCJKsc-Regular',
'NotoSans-SemiCondensed'
@@ -147,11 +140,9 @@ class Today(inkycal_module):
logger.debug(f'Selected font: {font_name}')
return font_name
# 如果都不存在,使用第一个可用字体
return list(fonts.keys())[0]
def _get_font(self, size: int) -> ImageFont.FreeTypeFont:
"""获取指定大小的字体"""
return ImageFont.truetype(fonts[self._font_family], size=size)
@staticmethod
@@ -272,6 +263,16 @@ class Today(inkycal_module):
from inkycal.modules.super_productivity_utils import get_today_tasks
import requests
url = self.webdav_options['webdav_hostname'] + self.webdav_options['webdav_file_path']
response = requests.get(url, auth=(
self.webdav_options['webdav_login'],
self.webdav_options['webdav_password']
))
content = response.content
content = content[8:]
with open('/workspaces/Inkycal/inkycal/modules/super_productivity.json', 'wb') as f:
f.write(content)
json_file_path = '/workspaces/Inkycal/inkycal/modules/super_productivity.json'
task_list = get_today_tasks(json_file_path)
@@ -327,7 +328,7 @@ class Today(inkycal_module):
else:
# 没有事件时显示提示
write(
im_black,
im_colour,
(right_x, int(im_height / 2)),
(right_usable_width, line_height),
"No events today",